Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

llHttpRequest Tutorial needed

Cherry Hainsworth
Registered User
Join date: 31 Jul 2006
Posts: 125
02-19-2009 15:09
I've read everything I can find about it, but I STILL don't understand how to get data back & forth between an in-world object and my database.

I'm OK with the PHP and MySQL, it's the LSL that has me flummoxed!

My object is supposed to report data about itself, its owner and its history, which is in a scripted list. There's quite a lot of info but, if I ever figure this out, the web server should be able to feed updates back to the script - is that correct?

I confess I only ever do Ajax & curl requests using libraries; I don't know how to write them from scratch which is probably why I'm having so much trouble with this ...

Does anybody know of a complete, baby-steps, ground-up tutorial on how to effect data transfers with LSL?

I hope so!!

Thanks,
Cherry
_____________________
=================
My stuff on XSt:-
http://tinyurl.com/383mgh
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
02-20-2009 00:03
Beats me, but http://www.lslwiki.net/lslwiki/wakka.php?wakka=llHTTPRequest has a pretty good (though simple) little example in there. It shows how to pass a parameter and how to get back a body. I'd be willing to bet that if you did a search for "llHTTPRequest" in this forum you'd come up with lots of examples as well.
Cherry Hainsworth
Registered User
Join date: 31 Jul 2006
Posts: 125
02-20-2009 15:00
Yup - Thanks, Hewee, there is loads of stuff but nothing that seems - umm, both simple enough in its approach and detailed enough in its aims. I guess I'll just have to slog through it. As I've now "downsized" to minimum tier, at least I've got time to experiment :)

*When* I've cracked it, I'll post my idea of a walk-through here.
Appreciate your reply; I was feeling lonely!

Cherry
_____________________
=================
My stuff on XSt:-
http://tinyurl.com/383mgh
ElQ Homewood
Sleeps Professionally
Join date: 25 Apr 2007
Posts: 280
02-21-2009 04:04
yanno, I picked up a tutorial that dealt with llHTTPRequest and XML-RPC quite a while back. It really helped me "get it" as far as the barebones working of it. I'll have to look around in inv, though, when I get inworld. If I can find it, I'll pass one to you, I'm pretty sure it was a freebie..this ringing a bell with anybody?
Cherry Hainsworth
Registered User
Join date: 31 Jul 2006
Posts: 125
02-21-2009 09:09
No ... but I hope you find it!!

Cherry
_____________________
=================
My stuff on XSt:-
http://tinyurl.com/383mgh
Darien Caldwell
Registered User
Join date: 12 Oct 2006
Posts: 3,127
02-23-2009 12:52
http://www.xstreetsl.com/modules.php?name=Marketplace&file=item&ItemID=255083
_____________________
Papalopulus Kobolowski
working mind
Join date: 11 Aug 2006
Posts: 326
02-23-2009 22:31
Ok lets try some basic steps..
first you need a web server and Mysql database(can be in your computer running xamp for example)

lsl side:
key request_id;
key usrNow;

default
{
state_entry()
{
llSay(0,"Im ready for some request..";);
}

touch_start(integer total_number)
{
usrNow=llDetectedKey(0);


request_id= llHTTPRequest( "http://your-site/yourphpfile.php", [HTTP_METHOD,"POST",HTTP_MIMETYPE,"application/x-www-form-urlencoded"],"toucher=" + llKey2Name(usrNow));

}
http_response(key requestid, integer status, list metadata, string body)

{

if(request_id==requestid) //for some verification, you can have several diferent httprequest and in this way you can diference between each one
{

llSay(0,"body";);

}


}
}
[/CODE]

PHP side:

CODE


<?

//your host db conection if you need it

$toucher = $_POST['toucher'];// the data incoming from the SL side

////////
//some sql sintax using the data from SL
////////

echo $toucher; //this will answer the same string you send it , it can be any data or result from the sql execution

/////
// //Or can be several data Concatenated with some caracter like a separator
//// echo $toucher."@".$data1."@".$data2;
////and then you can parse the data from the body response with lsl
////something like this
//// LSL////
//// list web_data = llParseString2List(body,["@"],[]);
//// this will parse into a list the message from the php side
//// then you can use the data from the list to do something...
//// string data0=llList2String(web_data,0);
//// string data1=llList2String(web_data,1);
//// and so on.

?>

_____________________


RAW terrain files - terraform your SIM!!
http://www.wishland.info/
PD:the wiki its your friend ;)
http://wiki.secondlife.com/wiki/LSL_Portal