LlHTTPRequest

De DigiWiki.

Version du 25 août 2012 à 18:40 par Djphil (discuter | contributions)
(diff) ← Version précédente | Voir la version courante (diff) | Version suivante → (diff)
key http_request_id;
 
default
{
    state_entry()
    {
        http_request_id = llHTTPRequest("url", [], "");
    }
 
    http_response(key request_id, integer status, list metadata, string body)
    {
        if (request_id == http_request_id)
        {
            llSetText(body, <0,0,1>, 1);
        }
    }
}

Example PHP test script:

<?php header("content-type: text/plain; charset=utf-8"); ?>
Headers received:
<?php
 
/**
 * @author Wouter Hobble
 * @copyright 2008
 */
 
foreach ($_SERVER as $k => $v)
{
	if( substr($k, 0, 5) == 'HTTP_')
	{
		print "\n". $k. "\t". $v;
	}
}
?>

example wrapper script Both capturing apache headers and global methodes

<?PHP
	// Author Waster Skronski.
	// General Public License (GPL).
	// Mind that some headers are not included because they're either useless or unreliable.
	$USE_APACHE_HEADERS = TRUE; // switch to false if you need cgi methods
	if ($USE_APACHE_HEADERS)
	{
		$headers 	= apache_request_headers();
		$objectgrid 	= $headers["X-SecondLife-Shard"];
		$objectname 	= $headers["X-SecondLife-Object-Name"];
		$objectkey     	= $headers["X-SecondLife-Object-Key"];
		$objectpos 	= $headers["X-SecondLife-Local-Position"];
		$ownerkey     	= $headers["X-SecondLife-Owner-Key"];
		$ownername 	= $headers["X-SecondLife-Owner-Name"];
		$regiondata     = $headers["X-SecondLife-Region"];
		$regiontmp 	= explode ("(",$regiondata); // cut cords off 
		$regionpos 	= explode (")",$regiontmp[1]); //
		$regionname 	= substr($regiontmp[0],0,-1); // cut last space from simname
	} else {
		$db = $GLOBALS;
		$headers 		= $db['HTTP_ENV_VARS'];
		$objectgrid 	= $headers["HTTP_X_SECONDLIFE_SHARD"]; 
		$objectname 	= $headers["HTTP_X_SECONDLIFE_OBJECT_NAME"];
		$objectkey     	= $headers["HTTP_X_SECONDLIFE_OBJECT_KEY"];
		$ownerkey     	= $headers["HTTP_X_SECONDLIFE_OWNER_KEY"];
		$objectpos     	= $headers["HTTP_X_SECONDLIFE_LOCAL_POSITION"];
		$ownername 	= $headers["HTTP_X_SECONDLIFE_OWNER_NAME"];
		$regiondata     = $headers["HTTP_X_SECONDLIFE_REGION"];
		$regiontmp 	= explode ("(",$regiondata); 
		$regionpos 	= explode (")",$regiontmp[1]);
		$regionname 	= substr($regiontmp[0],0,-1);
	}
?>
Outils personnels
donate
Google Ads