Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

llHttpRequest help

Gwylym Loon
Registered User
Join date: 6 Jun 2007
Posts: 81
01-20-2010 14:22
I am working on a wedding and want to feed a list of names via a notecard and have the script take the names and lookup the key for each.

I have no probs getting the names in. But what I am having probs with is processing the http requests in a sequential fashion. Here are som e code snippets. First is a function that goes thru the list:

CODE

send_invites() {
llSay(0,"Sending invitations.");
integer i;

for (i=0;i < nNames;i++) {
NAME=llStringTrim(llList2String(names,i),STRING_TRIM);
llOwnerSay("Sending to "+NAME);
reqid = llHTTPRequest( URL + "?terse=1&name=" +
llEscapeURL(NAME), [], "" );
}
}


The httpresponse is as follows:

CODE

http_response(key id, integer status, list meta, string body) {
//llOwnerSay("id="+(string)id+" status="+(string)status+" body="+body+" reqid="+(string)reqid);
if ( id != reqid )
return;
if ( status == 499 )
llOwnerSay("name2key request timed out");
else if ( status != 200 )
llOwnerSay("the internet exploded!!");
else if ( (key)body == NULL_KEY )
llOwnerSay("No key found for " + NAME);
else{
llOwnerSay(NAME + "'s key is: " + body );
}
}


I'm just printing out each person's key for now. Anyone know how to get this to flow for each name in the list?

Thanks.
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
01-20-2010 14:23
Ummmmm..... It worked?
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask.... ;)

Look for my work in XStreetSL at
Gwylym Loon
Registered User
Join date: 6 Jun 2007
Posts: 81
01-20-2010 14:24
From: Rolig Loon
Ummmmm..... It worked?


How the heck do I post code snippets?
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
01-20-2010 14:27
That's easy... almost. Just be sure that any "< " signs don't have non-numeric characters after them or the forums will spit the post back at you. There are few other arcane warnings, but that's the biggie. Oh, and for everyone's convenience in reading your code, put
CODE
 .... 
markers around it so the forum preserves your indentation.

Good luck .... from one Loon to another. ;)

ETA: Those other arcane warnings are at
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask.... ;)

Look for my work in XStreetSL at
Gwylym Loon
Registered User
Join date: 6 Jun 2007
Posts: 81
01-20-2010 14:30
From: Rolig Loon
That's easy... almost. Just be sure that any "< " signs don't have non-numeric characters after them or the forums will spit the post back at you. There are few other arcane warnings, but that's the biggie. Oh, and for everyone's convenience in reading your code, put
CODE
 .... 
markers around it so the forum preserves your indentation.

Good luck .... from one Loon to another. ;)


Tried the php /php markers and no luck. When I have the code snippets in there it says that the newthread.php or editthread.php script does not exist on an error page.
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
01-20-2010 14:32
The tags work like this.....

CODE

default
{
state_entry()
{
llSay(0,"This is dummy code.");
}
}


They won't affect whether the code gets posted or not, but they do make a difference when it comes to readability. The business with the < symbols is what usually kills a post.
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask.... ;)

Look for my work in XStreetSL at
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
01-20-2010 14:41
From: Gwylym Loon
I am working on a wedding and want to feed a list of names via a notecard and have the script take the names and lookup the key for each.

I have no probs getting the names in. But what I am having probs with is processing the http requests in a sequential fashion. Here are som e code snippets. First is a function that goes thru the list:

CODE

send_invites() {
llSay(0,"Sending invitations.");
integer i;

for (i=0;i < nNames;i++) {
NAME=llStringTrim(llList2String(names,i),STRING_TRIM);
llOwnerSay("Sending to "+NAME);
reqid = llHTTPRequest( URL + "?terse=1&name=" +
llEscapeURL(NAME), [], "" );
}
}


The httpresponse is as follows:

CODE

http_response(key id, integer status, list meta, string body) {
//llOwnerSay("id="+(string)id+" status="+(string)status+" body="+body+" reqid="+(string)reqid);
if ( id != reqid )
return;
if ( status == 499 )
llOwnerSay("name2key request timed out");
else if ( status != 200 )
llOwnerSay("the internet exploded!!");
else if ( (key)body == NULL_KEY )
llOwnerSay("No key found for " + NAME);
else{
llOwnerSay(NAME + "'s key is: " + body );
}
}


I'm just printing out each person's key for now. Anyone know how to get this to flow for each name in the list?

Thanks.

Well, I'm glad we solved the posting problem.... :)

Yes... Instead of doing your successive calls to http_response from a function, do it from inside the http_response event itself.
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask.... ;)

Look for my work in XStreetSL at
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
01-20-2010 14:58
I think this will work.

CODE

http_response(key id, integer status, list meta, string body) {
//llOwnerSay("id="+(string)id+" status="+(string)status+" body="+body+" reqid="+(string)reqid);
integer i;
if ( id != reqid )
return;
if ( status == 499 )
llOwnerSay("name2key request timed out");
else if ( status != 200 )
llOwnerSay("the internet exploded!!");
else if ( (key)body == NULL_KEY )
llOwnerSay("No key found for " + NAME);
else{
llOwnerSay(NAME + "'s key is: " + body );
}
if (++i < nNames)
{
NAME=llStringTrim(llList2String(names,i),STRING_TRIM);
llOwnerSay("Sending to "+NAME);
reqid = llHTTPRequest( URL + "?terse=1&name=" +
llEscapeURL(NAME), [], "" );
}

}


ETA: You obviously have to make your initial call from outside the event:

CODE

NAME=llStringTrim(llList2String(names,0),STRING_TRIM);
llOwnerSay("Sending to "+NAME);
reqid = llHTTPRequest( URL + "?terse=1&name=" +
llEscapeURL(NAME), [], "" );
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask.... ;)

Look for my work in XStreetSL at
Gwylym Loon
Registered User
Join date: 6 Jun 2007
Posts: 81
01-20-2010 15:00
Ah, very good. I didn't think of treating it like dataserver. I think I have it working now. Thank you.

makes my life so much easier.
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
01-20-2010 15:04
Cool. Good luck with it.
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask.... ;)

Look for my work in XStreetSL at
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
01-20-2010 16:09
From: Rolig Loon
I think this will work.


CODE

http_response(key id, integer status, list meta, string body) {
//llOwnerSay("id="+(string)id+" status="+(string)status+" body="+body+" reqid="+(string)reqid);
integer i;<-- not where you want to declare that, needs to be global ;)
if ( id != reqid )
return;
if ( status == 499 )
llOwnerSay("name2key request timed out");
else if ( status != 200 )
llOwnerSay("the internet exploded!!");
else if ( (key)body == NULL_KEY )
llOwnerSay("No key found for " + NAME);
else{
llOwnerSay(NAME + "'s key is: " + body );
}
if (++i < nNames)
{
NAME=llStringTrim(llList2String(names,i),STRING_TRIM);
llOwnerSay("Sending to "+NAME);
reqid = llHTTPRequest( URL + "?terse=1&name=" +
llEscapeURL(NAME), [], "" );
}
}

but the concept is there... treat it just like a notecard reader
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
01-20-2010 17:17
Ooops. Right. :o
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask.... ;)

Look for my work in XStreetSL at