Jump to content

llHTTPRequest issue: seems don't send GET vars


Moore Tone
 Share

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

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

Recommended Posts

Sorry to bother for a silly question like that, but it puzzles me about 2 hours.
What I want is simply send by lsl a GET var to a php page and get the same value as answer in the http_response( )

Here what I wrote:

LSL script:

string myurl ="http://*****/test0.php"; //obfuscate for privcy : P
key http_request_id;

default
{
  state_entry() { llOwnerSay("Run"); } //don't do nothing special

  touch_start(integer total_number)
  {
    llOwnerSay("Touched.");

    http_request_id = llHTTPRequest(
      myurl, 
      [HTTP_METHOD, "GET", HTTP_MIMETYPE, "application/x-www-form-urlencoded"],
       "p2=test");
  }//touch_start

  http_response(key request_id, integer status, list metadata, string body)
  {
    if (request_id != http_request_id) return;// exit if unknown
    llOwnerSay("-" + (string)status + " - " + body  + "- ");
  }
}

 -----

PHP code:

<?php
$servervar1 = "nothing here";

if( $_GET['p2'] != NULL ){
  $servervar1 = $_GET['p2'];
} else {
  $servervar1 = "p2 var is NULL or doesn't exist";
}

echo("--".$servervar1."--".);
?>

 -----

Everything goes fine  with no problem but despite any effort I keep get the FAIL message:

-200 - --p2 var is NULL or doesn't exist--- 

I also checked the same url via browser and it works correctly

I also checked using the LSL script if -any- $_GET[ ] reach the php page counting the length of the $_GET[ ] array (...sizeof($_GET)...) but keep telling me 0 elements.

So, seems my php page don't see the GET var coming from the LSL script..but don't have any idea why!
 -----

Somebody could help me?

Link to comment
Share on other sites

Just to elaborate on what ObviousAltIsObvious said:

The $_GET variable in PHP get populated by the key-value-pairs in the URL of a GET request. You put your values in the body of the HTTP-request, not in the URL, so the $_GET variable in PHP will be empty. The body is used in a POST request to pass the key-value-pairs.

  • Like 1
Link to comment
Share on other sites

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...