Php + Lsl
|
|
Zany Porthos
Registered User
Join date: 24 Jan 2009
Posts: 3
|
02-05-2009 06:21
I saw a website yesterday that had a link, and when I clicked it I received an item in SL(some ball promoting the website).. I don't know if I can put the URL of the site here so I won't. If someone needs it to see what I'm talking about, to help me, please send me a message. The thing is, I have a website and I would like to give shirts with my website logo using a system like this. Can someone give me some ideas of how can I do it? I'm not asking for code, just the name of some functions that can help me, then I do the search, help me how you can.
Thanks
|
|
Pedro McMillan
SLOODLE Developer
Join date: 28 Jul 2007
Posts: 231
|
02-05-2009 07:05
I think the fastest way to do it at the moment is using XMLRPC: http://www.lslwiki.net/lslwiki/wakka.php?wakka=XMLRPCIn SL, you need to open a remote data channel (llOpenRemoteDataChannel), and your script will get a UUID key for that channel (in the remote_data event). You then communicate it to your server using llHTTPRequest or whatever. When somebody clicks a link/button on your site, PHP can send an XMLRPC into SL, using the key provided, containing the UUID of the avatar. When the RPC arrives at your LSL script (again, in the remote_data event), you then process it to figure out who the item is to be sent to, and use llGiveInventory to do the rest. (Note: the RPC can consist of a string and an integer -- UUID keys can easily be converted to and from strings.) Some configurations of PHP have XMLRPC built-in already, but you may also have to get a 3rd party library. There are one or two on SourceForge I think.
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
02-05-2009 08:37
You can also have an in-world object poll your web server periodically to see if there is anything to send. That is the more common option, I believe. It is also a lot more stable and reliable, as XMLRPC is buggy and broken, and it seems LL is trying very hard NOT to support it. "Soon" we'll have HTTP-in, so you'll be able to actually make an HTTP request in to your object. If you can get around the temporary URL issue at any rate (shouldn't be a big deal for THIS kind of application, because the object can do an HTTP request to the web server whenever the URL changes, re-registering itself with the new URL).
Incidentally, you had to enter your SL name on the website, right? You didn't just click and get the object? I can't really think of a way to make it work without asking you who you are in-world.
|
|
Zany Porthos
Registered User
Join date: 24 Jan 2009
Posts: 3
|
02-05-2009 09:13
Thanks a lot for your answers. I will work on that later today, and yes I gave my SL name. I think I will try the http server and deal with the temporary url.
|
|
Zany Porthos
Registered User
Join date: 24 Jan 2009
Posts: 3
|
02-05-2009 11:30
I'm trying the sample script at http://wiki.secondlife.com/wiki/LSL_http_server/examples but it always says syntax error on the "http_request(key id, string method, string body)" line
|
|
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
|
02-05-2009 12:08
I don't understand how this example works either, but I have only been scripting in LSL for a short time. I can't find any documentation for a llRequestURL function or for a http_request event anywhere. Am I missing something?
|
|
Pedro McMillan
SLOODLE Developer
Join date: 28 Jul 2007
Posts: 231
|
02-05-2009 12:20
The http-in stuff? You have to be working on the beta grid to use it just now, as it hasn't been properly released yet.
|
|
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
|
02-05-2009 12:25
Gotcha. So the http_request examples on  were posted a little prematurely, then?
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
02-05-2009 17:20
From: Pedro McMillan The http-in stuff? You have to be working on the beta grid to use it just now, as it hasn't been properly released yet. Specifically, you have to be in one of I think 2 or 4 regions in the Beta Grid. See http://wiki.secondlife.com/wiki/LSL_http_server/beta
|
|
Pedro McMillan
SLOODLE Developer
Join date: 28 Jul 2007
Posts: 231
|
02-06-2009 01:43
Oh I hadn't realised that -- thanks for the clarification Hewee. I kept meaning to test it out myself, but I never got round to actually using the beta grid at all. Busy busy busy!
|
|
Elanthius Flagstaff
Registered User
Join date: 30 Apr 2006
Posts: 1,534
|
02-06-2009 01:56
Personally I find it easier to email the object and have the object polling it's incoming mail queue regularly. It's a simpler solution than XML-RPC and it doesn't bog down your server like polling does.
_____________________
Visit http://ninjaland.net for mainland and covenant rentals or visit our amazing land store at Steamboat (199, 56). Also, we pay L$0.15/sqm/week for tier donated to our group and we rent pure tier to your group for L$0.25/sqm/week. Free L$ for Everyone - http://ninjaland.net/tools/search-scumming/
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
02-06-2009 02:59
From: Elanthius Flagstaff Personally I find it easier to email the object and have the object polling it's incoming mail queue regularly. It's a simpler solution than XML-RPC and it doesn't bog down your server like polling does. Unfortunately it is also buggy though. E-mail to objects from out-of-world has been broken (periodically or still) for some time. Most or all such e-mails either never arrive or are delayed for long enough that it makes no difference.
|
|
Elanthius Flagstaff
Registered User
Join date: 30 Apr 2006
Posts: 1,534
|
02-06-2009 03:01
From: Hewee Zetkin Unfortunately it is also buggy though. E-mail to objects from out-of-world has been broken (periodically or still) for some time. Most or all such e-mails either never arrive or are delayed for long enough that it makes no difference. Well, I've been using this feature for a while have never experienced a problem.
_____________________
Visit http://ninjaland.net for mainland and covenant rentals or visit our amazing land store at Steamboat (199, 56). Also, we pay L$0.15/sqm/week for tier donated to our group and we rent pure tier to your group for L$0.25/sqm/week. Free L$ for Everyone - http://ninjaland.net/tools/search-scumming/
|
|
Pedro McMillan
SLOODLE Developer
Join date: 28 Jul 2007
Posts: 231
|
02-06-2009 04:56
I find email into SL can be a bit slow, and indeed, doesn't always arrive... although it only seems to be occasional problems rather than all the time. We only use email for non-critical stuff in SLOODLE, for example -- if an avatar uses a tool, then (if necessary and possible) a new web-account is automatically setup for them on the external website. A regular cron job looks through the list of auto-created accounts, and sends out an email to the object the avatar originally used, containing the username/password for logging-in to the website, which then relays it via IM. (The plaintext password is only stored until the email is sent, and thereafter it's encrypted.)
It normally seems to work fine, but just in case, we have a backup "Password Reset" device which will use an HTTP request to request and fetch a new password for the user.
|