Jump to content

HTTP Get Request ???


Aimee Dakota
 Share

You are about to reply to a thread that has been inactive for 3010 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Hi All,

 

I am an Absolute Scripting Noob... I need a Script so I can click an Object and it opens a Blue Menu with 2 Options, Option 1 Sends a Notecard and Option 2 makes a HTTP GET Request to a URL and then reads the API Response and says "Completed" or "Rejected" based on the API "Success" or "Fail"

 

Does anyone have an Example Script that could give me some Headway? or a Reference. Trying to send a URL to an API to Generate a Response... then Show that Response to the Original Clicker.. on Click

Link to comment
Share on other sites

First you would need a Dialog  function to open the blue boxes....

http://wiki.secondlife.com/wiki/LlDialog

 

and a detected function to identify who is touching ....

http://wiki.secondlife.com/wiki/LlDetectedKey

 

and the notecard giver as described above...

 

 for the HTTP stuff, here is a snippet ( not  a whole code) to give you an idea of how it works...

 

integer chan;
key http_request_id;
string BASE_URL = "https://docs.google.com/document/d/*****************************";
string SUFFIXE_URL = "/export?exportFormat=txt";
list Rangers;

string URL;
init()
{ URL = BASE_URL + SUFFIXE_URL;

http_request_id = llHTTPRequest(URL ,
[HTTP_METHOD, "GET",
HTTP_MIMETYPE, "text/plain",
HTTP_BODY_MAXLENGTH,16384,
HTTP_PRAGMA_NO_CACHE,TRUE], "");
}
default
{
state_entry()
{ init();
}
on_rez(integer param)
{ init();
}
http_response(key request_id, integer status, list metadata, string body)
{ if (request_id != http_request_id) return;// exit if unknown
if(status != 200)
{llOwnerSay("FAIL - Unable to get google Doc");return;} // CHANGE this part for your success/fail message
llOwnerSay("SUCCESS!");                                              // CHANGE this part for your success/fail message
body = llUnescapeURL(body);
Rangers = llParseString2List(body,["\n"],[""]);
}
}

 

Instead of llOwnerSay()  you can send a msg to the toucher by using llSay() .. or llInstantMessage() to the detected key.

 

hope this helps

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 3010 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...