Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

llHTTPRequest

Rachel Corleone
Registered User
Join date: 9 Oct 2006
Posts: 21
11-17-2007 09:58
I'm trying to establish a connection between my LSL script and a php script on my home computer. I'm pretty sure I've got the syntax correct (I followed some examples posted on the wiki pretty closely), but all I get back from the script is the php code itself. What am I doing wrong?


string URL = "http://my.home.computer/sldata.php";
key http;

default
{
touch_start(integer foo)
{
http = llHTTPRequest( URL,
[HTTP_METHOD, "POST"],
"sldata=12345";);
}

http_response(key id, integer status, list meta, string body)
{
if( http == id )
{
integer i;
list lbody = llParseString2List( body, ["\n"], [] );
integer count = llGetListLength( lbody );
for( i = 0; i < count; i++ )
{
llOwnerSay( llList2String( lbody,i ) );
}
}
}
}

And here's what I get back:

<?php
$sldata = $_POST["sldata"];
echo "Data: " . $sldata;
?>

What I want to get, of course, is "12345".

Rachel
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
11-17-2007 16:32
something is wrong with your php server
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
11-17-2007 18:00
if you are getting the whole php script back, it would seem that php isn't enabled (at least in that folder)
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Csteph Submariner
Registered User
Join date: 24 Apr 2007
Posts: 60
11-18-2007 04:18
As other have said, it looks like a problem with your server rather than anything wrong in the LSL.

Do other PHP scripts run on the server? If not then you need to look at the web server config files and tell it that files ending .php are processed by the php executable.

There are tons of articles on the web describing in detail how to do this for most web servers.
Rachel Corleone
Registered User
Join date: 9 Oct 2006
Posts: 21
PHP down
11-18-2007 06:39
Yes, you're all right... PHP scripts won't run at all on my computer. I just upgraded to Leopard, and lots of stuff is broken. That's the last time I'll be a version.0 adopter!

Rachel