Jump to content

What is HTTP for?


Xiija
 Share

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

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

Recommended Posts

HI,

 I want to pull names from a google doc using an Object in SL.

 the google page is https ... is that a problem?

does http need php to work?

 the code i have now is returning a status 400 

 i don't even know if this is what http is for?

the BODY is set to hover text .. but it is just header gibberish, and only a few lines?

 

key http_request_id;
// string URL = "https://my.secondlife.com/xiija/groups/";
 
  
   string URL = "https://docs.google.com/document/d/1CkDj9dCAfK46J9I_AjNI-_7EvSGmRuGzSev2NRx7v8A/edit?usp=sharing";
 string tag = " HTTP/1.0\nUser-Agent: LSL Script (Mozilla Compatible)\n\n";
default
{
    state_entry()
    {     // [HTTP_METHOD,"GET"],"");            "text/plain;charset=utf-8"     "application/x-www-form-urlencoded"
         // application/vnd.google-apps.document
          //application/vnd.google-apps.kix
        http_request_id = llHTTPRequest(URL + tag ,
                          [HTTP_METHOD,   "GET", 
                           HTTP_MIMETYPE, "application/vnd.google-apps.spreadsheet",
                           HTTP_BODY_MAXLENGTH,16384,
                           HTTP_PRAGMA_NO_CACHE,TRUE], ""); 
    }
 
    http_response(key request_id, integer status, list metadata, string body)
    {
        if (request_id != http_request_id) return;// exit if unknown
 
        vector COLOR_BLUE = <0.0, 1.0, 0.0>;
        float  OPAQUE     = 1.0;
 
        llSetText(body, COLOR_BLUE, OPAQUE);
        llOwnerSay("\nstat : " + (string)status + "\nmeta : " + llDumpList2String(metadata," , ") );
    }
}

 

thnaks for any info

 

 

Link to comment
Share on other sites

If you do not use 'string tag' or do 'string tag = "" ' then you don't get a 400.

The string returned however is still far to small to contain the names on the list. Do a 'view page source' in your browser to see what gets returned and where, in between all that gibberish, the list with names are (hint: look for ' DOCS_modelChunk = [').

In other words, you do need some php or related language to do some preprosessing.

Or just use 'media on a prim'.

Link to comment
Share on other sites

google spreadsheet  and google document allows you to export your document as plain text .

Or as JSON  text .

 

So , maybe you will get less difficulties to parse your document .

 

Nevertheless you need to consult the documention of google about the URLs .

Your actual fields are "edit?sharing=xxx" . But with LSL , you don t want to edit it .

To export a document , the fields are  export?exportFormat=txt 

Change too the mimetype to text/plain

 

Let's fix your script:

 


key http_request_id;

// URL for my google document
string BASE_URL = "https://docs.google.com/document/d/1CkDj9dCAfK46J9I_AjNI-_7EvSGmRuGzSev2NRx7v8A";
// fields to add to the URL for a google document to watch it as text
string SUFFIXE_URL = "/export?exportFormat=txt";


default
{
state_entry()
{
string 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], "");
}

http_response(key request_id, integer status, list metadata, string body)
{
if (request_id != http_request_id) return;// exit if unknown

vector COLOR_BLUE = <0.0, 1.0, 0.0>;
float OPAQUE = 1.0;

llSetText(body, COLOR_BLUE, OPAQUE);
llOwnerSay("\nstat : " + (string)status + "\nmeta : " + llDumpList2String(metadata," , ") );
}
}

 

You may export to to tsv( tab separated text),  csv( comma separated text ) etc ....

 

For spreadsheet , by default the first sheet of the speadsheet is returned . If you want an another sheet you will need to specify the number of the sheet in the url ( &gid=2 or 3 or 4 etc .. )

With spreadsheets , you may specify too a range . So you won t need to fetch the whole sheet ; you will get only the interesting cells for you lsl script

If you use too google charts , you may use "named ranges" too . So if your range is dynamic and not static , you won t need to change your lsl script

If you are not english and you try to export to csv or tsv , fill the regional and international setteings for US English in your document ( inside the google page)  . For instance , in Europe , we use "," and not "." to decimate numbers . So when we export to csv,  if we have not  changed the international settings  , it will separate the frac and the non-frac.

 

 

And finally , the hover text  defined by llSetText is limited to 254 characters .

Inside your httpèresponse , maybe you can save the body of the http response in a string and write your string in several parts 

  • Like 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 3482 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...