Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Send XML RPC From Outside World to SL

CamperDave Proudfoot
(_)|33P\ 1337 $xor
Join date: 16 Sep 2004
Posts: 205
02-28-2005 14:35
How would I go about using this (Standard XML RPC PHP library I found a link to from the forums ) to send data to the SL object, and then have the SL Object act upon that data. I found an example that sneds data from second life to the PHP backend, but not the direction I want to go. :(
_____________________
The PWNED SHOP!


List of Cool Things I've done first... I think
  1. Put on sale a key mod that makes SL more like an FPS
  2. Made my own custom attachment points - looking for a good use
  3. Found "secret" login screen.
  4. Created a way to call Java methods from LSL --> Thread
Jeffrey Gomez
Cubed™
Join date: 11 Jun 2004
Posts: 3,522
02-28-2005 14:49
Two-way XML-RPC (in this case, XML-RPC calls IN) is actually a feature to be added in the near future I believe. Please stay tuned...
_____________________
---
Alexis Heiden
xcriteria
Join date: 15 Jan 2005
Posts: 80
02-28-2005 15:57
Just this morning I got XML-RPC to send data from a PHP script on my web site to a script in SL.

I started with the sample LSL script at http://secondlife.com/badgeo/wakka.php?wakka=XMLRPC and the PHP example at http://secondlife.com/badgeo/wakka.php?wakka=XMLRPCImplementations
CamperDave Proudfoot
(_)|33P\ 1337 $xor
Join date: 16 Sep 2004
Posts: 205
Complicated...
02-28-2005 19:08
How exactly did you get it to work?

Could I see an example? ex: Server code PHP
vs.
Script in LSL
_____________________
The PWNED SHOP!


List of Cool Things I've done first... I think
  1. Put on sale a key mod that makes SL more like an FPS
  2. Made my own custom attachment points - looking for a good use
  3. Found "secret" login screen.
  4. Created a way to call Java methods from LSL --> Thread
Alexis Heiden
xcriteria
Join date: 15 Jan 2005
Posts: 80
02-28-2005 20:26
I started by putting the "LSL Example" section from http://secondlife.com/badgeo/wakka.php?wakka=XMLRPC by itself in a script in a prim. (To do much you will need to edit the llRemoteDataReply line and the processing of sval, but the sample script will work if you send it the string "How are you?" from the PHP script.)

When you save/reset that script, it should say "Ready to receive requests on channel" and a channel identifier like "1321e686-ccf9-a954-f9b4-aa8d6caf2a3b". You must put that identifier in the PHP script and update it if you edit/reset the LSL script.

Next, I took the the PHP script from http://secondlife.com/badgeo/wakka.php?wakka=XMLRPCImplementations and added a bit of HTML and the following bit PHP:

<?php
echo "sending request";
$data = llRemoteData("1321e686-ccf9-a954-f9b4-aa8d6caf2a3b", 0, "How are you?";);
print_r($data); // print the array of data received
echo "<p>Reply: ";
echo $data["StringValue"]; // print just the string returned from SL
?>

Again, note that you must replace the "1321e686-ccf9-a954-f9b4-aa8d6caf2a3b" from the above llRemoteData call with the ID given to you by the LSL script when you start it.

The whole initial PHP file (the sample code and mine) I put together is viewable at http://xcriteria.net/sl.txt
CamperDave Proudfoot
(_)|33P\ 1337 $xor
Join date: 16 Sep 2004
Posts: 205
Error.
03-01-2005 04:37
I only changed that key, and changed llsay to llIM, with no errorr, but when I ran it on a server that ran other XML-RPC Code, it gives this error
From: someone
Fatal error: Call to undefined function: xmlrpc_encode_request() in /home/www/camperdave.freecoolsite.com/Second Life/Test.php on line 6


Now the code for the PHP part w/ error is:

CODE
<?php
function llRemoteData($channel, $intvalue, $stringvalue) {
$host = "xmlrpc.secondlife.com";
$port = 80;
$uri = "/cgi-bin/xmlrpc.cgi";
$request = xmlrpc_encode_request('llRemoteData',
array( 'Channel' => $channel,
'IntValue' => $intvalue,
'StringValue' => $stringvalue));
$fp = fsockopen($host, $port, $errno, $errstr);
$query = "POST " . $uri . " HTTP/1.0\n" .
"User_Agent: PHP XML-RPC Interface\n" .
"Host: " . $host . "\n" .
"Content-Type: text/xml\n" .
"Content-Length: " . strlen($request) . "\n\n" .
$request . "\n";

if (!fputs($fp, $query, strlen($query)))
return NULL; // some sort of write error occured

$xmlresp = "";

while (!feof($fp)) {
$response = fgets($fp);
// the line beginning with the xml header is the chunk of XML-RPC data
if (substr($response, 0, 5) == "<?xml") // wiki bug: >
$xmlresp = $response;
}

fclose($fp);
if ($xmlresp == "")
return NULL;
else
return xmlrpc_decode($xmlresp);
}
?>

<html>
<head></head>
<body>
<?php
echo "sending request";
$data = llRemoteData("3c4cf4a5-f684-a3ae-6c72-866acd4abf1a", 0, "How are you?");
print_r($data); // print the array of data received
echo "<p>Reply: ";
echo $data["StringValue"]; // print just the string returned from SL
?>
</body>
</html>


What is wrong with it?
I only changed that key....
_____________________
The PWNED SHOP!


List of Cool Things I've done first... I think
  1. Put on sale a key mod that makes SL more like an FPS
  2. Made my own custom attachment points - looking for a good use
  3. Found "secret" login screen.
  4. Created a way to call Java methods from LSL --> Thread