Mathieu Basiat
Wavemaster
Join date: 24 Apr 2006
Posts: 57
|
11-25-2006 09:37
Here's a little PHP code to grab transactions from your account page <?php
// INIT CURL $ch = curl_init();
// SET URL FOR THE POST FORM LOGIN curl_setopt($ch, CURLOPT_URL, 'https://secondlife.com/account/login.php?type=second-life-member&nextpage=/account/index.php');
// ENABLE HTTP POST curl_setopt ($ch, CURLOPT_POST, 1);
// SET POST PARAMETERS : FORM VALUES FOR EACH FIELD curl_setopt ($ch, CURLOPT_POSTFIELDS, 'form[type]=second-life-member&form[nextpage]=/account/index.php&form[persistent]=Y&form[username]=YOURFIRSTNAME&form[lastname]=YOURLASTNAME&form[password]=YOURPASSWORD&submit=Submit');
// IMITATE CLASSIC BROWSER'S BEHAVIOUR : HANDLE COOKIES curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
// DON'T VERIFY SSL curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
// DON'T PRINT curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
// EXECUTE 1st REQUEST (FORM LOGIN) $store = curl_exec ($ch);
// SET FILE TO DOWNLOAD CHANGE THISS TO SUIT YOUR NEEDS curl_setopt($ch, CURLOPT_URL, 'https://secondlife.com/downloads/transactions.php?date_start=2006-11-25&date_end=2006-11-25&type=xml&include_zero=no');
// EXECUTE 2nd REQUEST (FILE DOWNLOAD) $content = curl_exec ($ch);
// CLOSE CURL curl_close ($ch);
echo $content;
/* * At this point you can do do whatever you want * with the downloaded file stored in $content : * display it, save it as file, and so on. */
?>
|
Mathieu Basiat
Wavemaster
Join date: 24 Apr 2006
Posts: 57
|
03-24-2007 07:47
here's a bit more refined version for getlinden.php I'm not going to explain how to set up a database though...
<?php
$dbhost = 'localhost'; $dbuser = 'dbuser'; $dbpass = 'dbpassword'; $dbname = 'dbtable';
$day = date("j",mktime(0,0,0,date("m") ,date("d")-1,date("Y"))); settype($day, "int"); $month = date("n",mktime(0,0,0,date("m") ,date("d")-1,date("Y"))); settype($month, "int"); $year = date("Y",mktime(0,0,0,date("m") ,date("d")-1,date("Y"))); settype($year, "int");
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); mysql_select_db($dbname);
$i = 1;
// INIT CURL $ch = curl_init();
// SET URL FOR THE POST FORM LOGIN curl_setopt($ch, CURLOPT_URL, 'https://secure-web3.secondlife.com/account/login.php?type=second-life-member&nextpage=/account/index.php');
// ENABLE HTTP POST curl_setopt ($ch, CURLOPT_POST, 1);
// SET POST PARAMETERS : FORM VALUES FOR EACH FIELD curl_setopt ($ch, CURLOPT_POSTFIELDS, 'form[type]=second-life-member&form[nextpage]=/account/index.php&form[persistent]=Y&form[username]=SLFIRSTNAME&form[lastname]=SLLASTNAME&form[password]=SLPASSWORD&submit=Submit');
// IMITATE CLASSIC BROWSER'S BEHAVIOUR : HANDLE COOKIES curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
// DON'T VERIFY SSL curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
# Setting CURLOPT_RETURNTRANSFER variable to 1 will force cURL # not to print out the results of its query. # Instead, it will return the results as a string return value # from curl_exec() instead of the usual true/false. curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
// EXECUTE 1st REQUEST (FORM LOGIN) $store = curl_exec ($ch);
// SET FILE TO DOWNLOAD $xxx = "https://secure-web3.secondlife.com/downloads/transactions.php?date_start=" . $year . "-" . $month . "-". $day . "&date_end=" . $year . "-" . $month . "-" . $day . "&type=xml&include_zero=no"; curl_setopt($ch, CURLOPT_URL, $xxx);
//$fp = fopen("today.xml", "w"); //curl_setopt($ch, CURLOPT_FILE, $fp); // EXECUTE 2nd REQUEST (FILE DOWNLOAD) $content = curl_exec ($ch);
//fclose($fp); // CLOSE CURL curl_close ($ch);
preg_match_all('#<deposit>(.*)</deposit>#Us', $content, $records);
$total = 0; foreach ($records[1] as $record) { $total = $total + $record;
//echo $record, '<br />'; ### or mysql_query($sql) } //mysql_select_db($mysql); $query = "INSERT INTO dbtable (DAY, MONTH, YEAR, LINDEN, NAME) VALUES ('$day', '$month', '$year', '$total', 'purchase');"; mysql_query($query) or die('Error, insert query failed');
//echo $total;
/* At this point you can do do whatever you want with the downloaded file stored in $content : display it, save it as file, and so on. */
mysql_close($conn);
?>
|
Maris Kanto
Registered User
Join date: 4 Dec 2007
Posts: 47
|
04-15-2008 07:52
these return just one line of whole xml file.. and the rest is missing..
|