Search code examples
linden-scripting-language

Linden Scripting Language Post to PHP


When I send a request from a Linden Scripting Language script to PHP with LlHTTPRequest I don’t get the values in PHP:

Example: ( LSL )

if(group_invite == "yes")
{

    list agents = llParseString2List(this_agent_name, [" "], []);

    string params = llDumpList2String([
        "firstname=" + llList2String(agents, 0),
        "lastname=" + llList2String(agents, 1)],
        "&");

    llHTTPRequest(
        "http://mysite/post-page.php",
        [HTTP_METHOD,"POST"],
        params);
}

I never get firstname and lastname values.


Solution

  • To submit arguments in that format in a POST request, your request must have the Content-Type header set to application/x-www-form-urlencoded:

    llHttpRequest(
        "http://example.com/post-page.php",
        [HTTP_METHOD, "POST", HTTP_MIMETYPE, "application/x-www-form-urlencoded"],
        params);