A pretty dumb PHP/LSL problem
|
|
Ojo Bourjade
Registered User
Join date: 31 Oct 2006
Posts: 4
|
04-02-2007 01:54
Let me preface this by saying I'm 99% sure I've made a really silly mistake here. I've just spent way too much time hung up on this code and related projects, and can no longer see the wood for the trees. Here's my LSL front end: key req_id;
default { state_entry() { llListen(0, "", llGetOwner(), ""); } listen(integer channel, string name, key id, string message) { req_id = llHTTPRequest("http://valyyn.dyndns.org/aiml.php?name=", [HTTP_METHOD, "GET"], message); } http_response(key requestid, integer status, list metadata, string body) { if(req_id == requestid) { llSay(0, body); } }
touch_start(integer total_number) { llSay(0, "Touched."); } }
And here is my ridiculously basic PHP prototype script. I'm using the same front end with some other scripts that actually do something with the input, needless to say, but if I can get this working with my basic prototype, I can get it working with everything else: <?php $a = $_GET['name']; $return = $a.", greetings.";
echo $return; ?>
The PHP script will respond to manual input in a browser address bar (eg., typing in "http://valyyn.dyndns.org/proto.php?name=Ally" gets a response of "Ally, greetings."  , but just says ", greetings." if I speak to the SL object. I imagine it's a session related problem?
|
|
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
|
04-02-2007 02:46
You've not formatted your URL correctly for a get try req_id = llHTTPRequest("http://valyyn.dyndns.org/aiml.php?name="+message, [HTTP_METHOD, "GET"], ""  ; instead. GET works off URLs.
|
|
Ojo Bourjade
Registered User
Join date: 31 Oct 2006
Posts: 4
|
04-02-2007 02:49
From: Eloise Pasteur You've not formatted your URL correctly for a get try req_id = llHTTPRequest("http://valyyn.dyndns.org/aiml.php?name="+message, [HTTP_METHOD, "GET"], ""  ; instead. GET works off URLs. I knew it would be something silly that I missed! Thank you. 
|
|
Ojo Bourjade
Registered User
Join date: 31 Oct 2006
Posts: 4
|
04-02-2007 03:07
From: Ojo Bourjade I knew it would be something silly that I missed! Thank you.  OK, now it's just not doing anything at all! It responds with a blank message, even when I change it back to how it was before. 
|
|
nand Nerd
Flexi Fanatic
Join date: 4 Oct 2005
Posts: 427
|
04-02-2007 03:27
From: someone "http://valyyn.dyndns.org/proto.php?name=Ally" First think I've noticed is that the URLs you are using do not match. From: someone req_id = llHTTPRequest("http://valyyn.dyndns.org/aiml.php?name=", [HTTP_METHOD, "GET"], message); So I tried the following: req_id = llHTTPRequest("http://valyyn.dyndns.org/proto.php", [HTTP_METHOD, "GET"], "name=" + message);Which I expected to work as I've used this before but all I get is ", greetings." req_id = llHTTPRequest("http://valyyn.dyndns.org/proto.php?name=" + message, [HTTP_METHOD, "GET"], "");This works but to me it doesn't look like the correct way to use this function. The example posted on the wiki uses this method. EDIT: Okay I'll correct myself: The last example is the correct way to use GET, the body value is only used with POST and PUT: From: LSL Wiki body specifies the body of the HTTP request and is only used when HTTP_METHOD is POST or PUT.
_____________________
www.nandnerd.info http://ordinalmalaprop.com/forum - Ordinal Malaprop's Scripting Forum
|
|
Ojo Bourjade
Registered User
Join date: 31 Oct 2006
Posts: 4
|
04-02-2007 06:36
From: nand Nerd lots of stuff Yeah, I apologise, I'm working with two different PHP scripts with two different objects and hadn't realised that I'd copied the wrong one, hence two different URLs showing up. e.e It's been a long day. Edit: Found a fix to my other problem. ( My main problem now is that data passed from Second Life seems to lose any spaces! So if the input sent to the PHP script is "my name", the PHP script sees it as "myname".)
|
|
RJ Source
Green Sky Labs
Join date: 10 Jan 2007
Posts: 272
|
04-02-2007 06:51
From: Edit: Found a fix to my other problem. ([i My main problem now is that data passed from Second Life seems to lose any spaces! So if the input sent to the PHP script is "my name", the PHP script sees it as "myname".) [/i] Try changing message to llEscapeURL(message) (or the entire url) Rj
|
|
Sys Slade
Registered User
Join date: 15 Feb 2007
Posts: 626
|
04-02-2007 08:13
If you escape the entire URL, you end up with http:// turning into http%3A%2F%2F, which may or may not work. Better to just do the message, as you stated.
|