Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

llHttpRequest problems

Niko Bromberg
Registered User
Join date: 30 May 2008
Posts: 14
09-25-2008 02:01
Hello!

I am have made this script which sends a http request for information, this is then returned through an instant message. However I am having problems when testing it with other avatars (with the object not responding), I realize this is probably because the script is looking for llGetOwner, however I cant seem to get it working with other alternatives. Also I am finding it hard to prompt with llSay when an option on a list is pressed. Finally does anyone know if there is a better way to display a http response - through a notecard for example?

I realize i am asking for the moon on a stick here, but any help with any of the problems would be a huge help, I love you all. thanks:

key http_request_id;
string url = "http......";
integer CHANNEL = 42;
key id;
list MENU = ["Summary"];

default
{

touch_start(integer total_number)
{
llListen(0,"",llGetOwner(),"";);
llDialog(llDetectedKey(0), "Welcome to the .. terminal. \n\nPLEASE SELECT AN OPTION THEN ENTER YOUR NUMBER.", MENU, CHANNEL);
}
listen(integer channel, string name, key id, string message)
{
if (message == "Summary";)
{
llListen(0,"",llGetOwner(),"";);
llSay(0, "Please enter your number";); // this llSay does not happen for some reason
}
}
listen(integer channel, string name, key id, string message)
{
llSay(0, "Your borrower number is:" + message);

{
http_request_id = llHTTPRequest(url+ llEscapeURL(message) + "&Summary", [HTTP_METHOD, "GET"], "";);
}
}


http_response(key request_id, integer status, list metadata, string body)
{
if ( request_id == http_request_id )
{
llInstantMessage ( llGetOwner(), "INFORMATION" + body );
}
}


}
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
09-25-2008 03:27
You'll want a list of http_request_ids and the keys of the associated agents to whom the responses should go.

But there are other problems here, too. There seem to be two listen() event handlers... and llListen() for the dialog seems to be called on the owner instead of the llDetectedKey() of the touch_start() event (and, mysteriously, called again inside one of those listen() handlers).

Dunno if this is enough clues to work with--it's not a terribly long script, so I'm trying not to spoil all the fun. ;)

Oh, and since you can't write to a notecard, that wouldn't work for a response read-out. llInstantMessage is the best approach that comes to mind.
Alicia Sautereau
if (!social) hide;
Join date: 20 Feb 2007
Posts: 3,125
09-25-2008 08:30
out of my head with no actual testing (but it compiled)

CODE

key http_request_id;
string url = "http......";
integer CHANNEL = 42;
key userkey;
list MENU = ["Summary"];

default
{
state_entry()
{
llListen(CHANNEL,"","","");
}

touch_start(integer total_number)
{
if (userkey == "") {
userkey = llDetectedKey(0);
llDialog(userkey, "Welcome to the .. terminal. \n\nPLEASE SELECT AN OPTION THEN ENTER YOUR NUMBER.", MENU, CHANNEL);
} else {
llSay(0, "In use by "+ llKey2Name(userkey));
}
}

listen(integer channel, string name, key id, string message)
{
if (id == userkey) {
if (message == "Summary") {
llSay(0, "Please enter your number"); // this llSay does not happen for some reason
} else {
llSay(0, "Your borrower number is:" + message);
http_request_id = llHTTPRequest(url+ llEscapeURL(message) + "&Summary", [HTTP_METHOD, "GET"], "");
}
}
}


http_response(key request_id, integer status, list metadata, string body)
{
if (request_id == http_request_id) {
llInstantMessage (userkey, "INFORMATION"+ body);
userkey = "";
}
}
}

problem was multiple listen(), multiple llListen(), mismatched { } in places they shouldn`t belong and a couple other things
best to just look at the changed and go from there ;)