Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Downloading transaction history

Seer Xingjian
Registered User
Join date: 29 Sep 2005
Posts: 35
06-04-2007 15:49
Does anyone have a lsl script or an externel code that can download the transaction history? I need to download my transaction history on a regular basis and i was hoping to auto-mate it with either lsl, .NET(C#) or php. I am currently having a problem to get these to work with the form authentication required the download the transaction history.

If anyone can help me that would be great.

Chris
Talarus Luan
Ancient Archaean Dragon
Join date: 18 Mar 2006
Posts: 4,831
06-04-2007 16:07
Not likely going to get it with LSL.

C++/C#, you can, as well as PHP, but it would be a serious mess to write, as you have to basically log in to the website, then navigate specific links (with redirects!) to the xml history download page (which would be preferable to scraping the account page version).

Then it is just a matter of parsing the returned data.

Simple, eh?
Seer Xingjian
Registered User
Join date: 29 Sep 2005
Posts: 35
06-04-2007 16:09
Once you are correctly authenticated it should not matter what page you go to if you have the url i just have an issue authenticating.
Talarus Luan
Ancient Archaean Dragon
Join date: 18 Mar 2006
Posts: 4,831
06-04-2007 16:21
It does if the page resides on a different server each session. :)

You'll note that every time you log in and navigate the secure, you are connecting to a different "secure-webn.secondlife.com" server for each session. Your code to do that has to therefore know which one you are connecting to.

I suppose you could just try connecting to secure-web1.secondlife.com all the time, but if it is down, or otherwise not allowing logins at the moment, then it will stop working.

As for having issues logging in at all, that's not surprising. I would expect them to make it fairly difficult for automated access to secure areas. You will have to pretty much make your back-end programs work the same way their login pages do, including adding any extra hidden POST data to secure forms to make it work.

Like I said, it IS doable; it's just not "easy".
Seer Xingjian
Registered User
Join date: 29 Sep 2005
Posts: 35
06-04-2007 16:47
Thanks for your help. Got a few hints from what you said along with stuff i already knew and it now works correctly. Sure it will be a problem if one of the web servers are down but i have a few ideas on how to get around that later on. For now i am just happy that i have it working correctly.

Thanks
Lee Lindman
Singularity Evangelist
Join date: 31 Jan 2007
Posts: 26
06-07-2007 03:37
Would you be able to share your experience in how you managed to pull this off, highlighting what language and techniques you used? I am Currently trying to do the exact same thing. Maybe PM or post some code samples?

Thanks,
LL
Tobia Forcella
Registered User
Join date: 4 Mar 2007
Posts: 30
06-07-2007 13:29
i have it done with php and curl functions.
But there is a big problem:
when i try to parse transactions, it give me back the result but it seems to be cached on the secondlife webserver; if i try after some time to parse again, it will give me the same result, ignoring the new transactions done.

Sorry for my english, if you are interested i can put here the code and try to solte it togheter :)
Cinos Yifu
Registered User
Join date: 23 May 2007
Posts: 1
06-07-2007 15:10
From: Lee Lindman
Would you be able to share your experience in how you managed to pull this off, highlighting what language and techniques you used? I am Currently trying to do the exact same thing. Maybe PM or post some code samples?

Thanks,
LL


Lee the code is done in C#. Just create a new console application in visual studio to test it. you need to replace some parts of the post data variable. xxx, yyy and zzz need to be replaced with your account details. Also the other claim that the details are chached are most likely correct as the screen does state the transaction history is cached for 15min. Nothing we can do about that execpt chech it every 16 min if you need to check it that offen :)

From: The Code

using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.IO;

namespace WebRequest
{
class Program
{


static void Main(string[] args)
{
string postData = "form[type]=second-life-member&form[nextpage]=/account/index.php&form[persistent]=Y&form[username]=xxx&form[lastname]=yyy&form[password]=zzz";

string TransactionXMLURL = "https://secure-web0.secondlife.com/downloads/transactions.php?date_start=2007-06-02&date_end=2007-06-04&type=xml&include_zero=yes";
string LOGIN_URL = "https://secure-web0.secondlife.com/account/login.php";
//string postData = String.Format("form[type]=second-life-member&UsernameTextBox={1}&PasswordTextBox={2}&LoginButton=Login", USERNAME, PASSWORD);
// have a cookie container ready to receive the forms auth cookie
CookieContainer cookies = new CookieContainer();
// now post to the login form
HttpWebRequest webRequest;
webRequest = (HttpWebRequest)HttpWebRequest.Create(LOGIN_URL) as HttpWebRequest;
webRequest.Method = "POST";
webRequest.ContentType = "application/x-www-form-urlencoded";
webRequest.CookieContainer = cookies;
// write the form values into the request message
StreamWriter requestWriter = new StreamWriter(webRequest.GetRequestStream());
requestWriter.Write(postData);
requestWriter.Close();


webRequest.GetResponse().Close();
// now we can send out cookie along with a request for the protected page
webRequest = (HttpWebRequest)HttpWebRequest.Create(TransactionXMLURL) as HttpWebRequest;
webRequest.CookieContainer = cookies;

HttpWebResponse response = (HttpWebResponse)webRequest.GetResponse();

if (webRequest.HaveResponse)
{
Console.WriteLine("Status code = " + response.StatusCode);
Console.WriteLine("Status Description = " + response.StatusDescription);
Console.WriteLine("Press enter to see response";);
Console.ReadLine();

StreamReader sr = new StreamReader(response.GetResponseStream());
while (!sr.EndOfStream)
{
Console.WriteLine(sr.ReadLine());
}
Console.WriteLine("Press enter to exit";);
Console.ReadLine();
sr.Close();
}

}
}
}