Jump to content

HTTP Request Body


UbiquitousStudio
 Share

You are about to reply to a thread that has been inactive for 2875 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Hello, I am trying to dabble more into http requests. I swear I had this working a little while ago. I am trying to just say in SL the body the a php page. I know I'm probably doing something silly here. Please help me

Here is the LSL

key httpkey;
string url = "Removed for no haxin";
list params = [HTTP_METHOD, "POST", HTTP_MIMETYPE, "application/x-www-form-urlencoded"];

string username;

default
{
    
    http_response(key request_id, integer status, list metadata, string body)
    {
        if(request_id == httpkey)
        {
            llOwnerSay("Body: " + body);    
        }
    }
    
    state_entry()
    {

    }

    touch_start(integer total_number)
    {

        httpkey == llHTTPRequest(url, params, "username=" + username); 
    }
}

Then some simple php that is just echoing a statement.

<?php
	echo "Worked?";
?>

Like I said I swear this worked for me before. I do not use free hosting and all my ports are open as I go through a game host. I just can't figure this out.

Please help! Thanks

Link to comment
Share on other sites

I don't know about the php end but on the lsl side you could try 

1 use an empty list for params 

httpkey == llHTTPRequest(url, [], "username=" + username)

2 c heck the status

http_response(key request_id, integer status, list metadata, string body)    {        if(request_id == httpkey)        {            llOwnerSay("Body: " + body);                llOwnerSay("Status: " + (string)status);        }
Link to comment
Share on other sites

That didn't work for me, as soon as I put the same script on a new object it just breaks the object completely.

I even tried just putting llOwnerSay("Touched"); In the state touched and nothing happens. There is no errors and I have had this working many times. It just doesn't return anything now.

Link to comment
Share on other sites


UbiquitousStudio wrote:

I even tried just putting llOwnerSay("Touched"); In the state touched and nothing happens.

Really? Is the "Running" box still checked? If so, that's pretty wild, and I'd try starting all over with a fresh object and new script, compiling it one line at a time.

I will note, though, that in touch_start there seems to be the comparison operator, "==", where I'd use the assignment operator, "=".  That may be why you're not matching the value later in http_response.

  • Like 1
Link to comment
Share on other sites

See I knew it was something super simple and silly I just did wrong and it turned out to be exactly that. I put two == instead of one cause I was just coding a bunch of php prior with that. I feel dumb now but I gave you kudos for helping!

Thanks so much for your time!

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 2875 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...