Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

XML-RPC -> I cant anymore :-(

Dennis Baxter
Registered User
Join date: 14 Dec 2006
Posts: 2
02-23-2007 11:20
Hi People!

I try 2 Weeks a simple XML-RPC request and it doesnt work. The Problem is, you cant find examples for help in Internet. What is false?
Can everybody help me? With an simple Example?

For example I had try this:

My Obejct in SL:

string EXPECTED_REQUEST_STRING_MESSAGE = "dennis";
string BAD_RESPONSE_STRING_MESSAGE = "I do not understand what you said";
string GOOD_RESPONSE_STRING_MESSAGE = "Hi.";
key myChannel;

default {
state_entry() {
llOwnerSay("Touch me to start listening for XML-RPC requests.";);
}

touch_start(integer n) {
llOpenRemoteDataChannel();
llOwnerSay("Waiting for channel to open";);
}

remote_data(integer type, key channel, key uid, string from, integer integerValue, string stringValue) {
if (type == REMOTE_DATA_CHANNEL) {
myChannel = channel;
llOwnerSay("Channel Open. Channel Key="+(string)channel);
state waiting;
}
}
}

state waiting {

state_entry() {
llOwnerSay("Waiting for XML-RPC Requests...";);
}

remote_data(integer type, key channel, key uid, string from, integer integerValue, string stringValue) {
if (type == REMOTE_DATA_REQUEST) {
if (stringValue == EXPECTED_REQUEST_STRING_MESSAGE) {
// uid is the identifier for the request message.
llRemoteDataReply(channel, uid, GOOD_RESPONSE_STRING_MESSAGE, 1);
llOwnerSay("hat geklappt!";);
} else {
llRemoteDataReply(channel, uid, BAD_RESPONSE_STRING_MESSAGE, 0);
}
} else {
// Code would go here to respond to a new open channel, etc...
// Check the options for 'type' in the LSL Wiki.
}
}

touch_start(integer n) {
state default;
}

state_exit() {
llCloseRemoteDataChannel(myChannel);
llOwnerSay("Channel closed. Touch again to start listening on channel.";);
}
}




And PHP:


<?

include('IXR_Library.inc.php');



$ll_packet = [
'Channel' => '0498b49d-a1aa-b12a-73ca-dbda7f82beaf',
'IntValue' => 32,
'StringValue' => 'dennis'];

// Create the client object
$client = new IXR_Client('http://xmlrpc.secondlife.com/cgi-bin/xmlrpc.cgi');

// Run a query for PHP
if (!$client->query('llRemoteData', $ll_packet)) {
die('Something went wrong - '.$client->getErrorCode().' : '.$client->getErrorMessage());
}



// Display the result
echo '<pre>';

print_r($client->getResponse());

echo '</pre>';

?>
Dennis Baxter
Registered User
Join date: 14 Dec 2006
Posts: 2
02-25-2007 06:10
hmmm. no answer :-(
JeeNate Arkin
Registered User
Join date: 26 Dec 2006
Posts: 2
04-02-2007 17:23
Hi Dennis,

Did you find the solution? If yes, please share it with us, so we may learn the process too...

Thanks in advance,
Diego Pannotia
Laronzo Fitzgerald
Join date: 14 Nov 2006
Posts: 37
04-02-2007 17:37
Dennis, make sure your objects channel hasn't changed. Channels will change now and then e.g. when the server is reset, every time you rez the object, if the object is attached to your avatar then it will also change eveyr time you log in, and every time you attach the object.

It would be easier if you sent the channel to your php script in an llHTTPRequest()

a simple example would be:

CODE

key gChannel;

DEBUG(list out)
{
llSay(0, llList2CSV(out));
}

default
{
state_entry()
{
llOpenRemoteDataChannel(); // Opens data channel to RL
}

remote_data(integer type, key channel, key message_id, string sender, integer ival, string sval)
{
if (type == REMOTE_DATA_CHANNEL)
{
gChannel = channel; // connects to RL

state on;
} else DEBUG(["Unexpected event type", type, channel, message_id, sender, ival, sval]);
}
}

state on // connected
{
state_entry()
{
llListen(1, "", NULL_KEY, "" ); // Listen on channel 1 for any chat
}

listen(integer channel, string name, key id, string message)
{
llHTTPRequest("www.xxx.com/xxx.php?message="+(string)gChannel+","+llEscapeURL(message),[HTTP_METHOD,"GET"],"");

// when chat received sends message to RL via HTTP request
// with the following syntax: "channel,message"
// you will need to handle this in your php script to extract the SL channel

llWhisper(0, message+ " request sent, please wait...");
}

remote_data(integer type, key channel, key message_id, string sender, integer ival, string sval)
{
if (type == REMOTE_DATA_REQUEST)
{
string stringPortionOfReply = "Default Reply";
integer intPortionOfReply = 0;

// once your PHP script has processed the message received
// via llHTTPRequest, process it and send a reply back on the
// channel given.

llWhisper(0, "...Thankyou, "+sval+" transaction complete");

// extracts the message and places it in a chat whisper
}

llRemoteDataReply(channel, message_id, stringPortionOfReply, intPortionOfReply);

} else DEBUG(["Unexpected event type:", type, channel, message_id, sender, ival, sval]);
}
}


Play around with something like that : )

Also, check your php script, I can't see a correctly formatted XML string there... lookup XML-RPC on the the lsl wiki for more info.

Mark.