[Slogger] SOLVED: How to submit to custom CGI script (was: Re: Feature request: submit to custom script)

Robin Smidsrød robin at smidsrod.no
Sun Jan 7 11:08:13 PST 2007


Thanks a lot for the quick reply. What it ended up with was this:

//Build ISO date string
var timestamp=sloggerGetVar("year") + '-'
+ sloggerGetVar("month") + '-'
+ sloggerGetVar("day") + 'T'
+ sloggerGetVar("hour") + ':'
+ sloggerGetVar("minute") + ':'
+ sloggerGetVar("second") + '.'
+ sloggerGetVar("millisecond");

// Build URL
var url = "http://xxx/cgi/slogger_recv.cgi?";
url += "username=xxx&";
url += "password=xxx&";
url += "machine=office&"; // or laptop, or living room, or whatever...
url += "timestamp=" + encodeURI(timestamp) + "&";
url += "url=" + encodeURI(sloggerGetVar("url")) + "&";
url += "title=" + encodeURI(sloggerGetVar("title")) + "&";

// Report URL
//alert(url);

var req = new XMLHttpRequest();
req.open('GET', url, true);
req.send(null);

This works as a charm, and is exactly what I was looking for. Now I just 
need to program that receiver CGI program. If any of you want this, give 
me a note.

Thanks for the help.

-- Robin

Ken Schutte wrote:
> Robin,
>
> This should be possible with a fairly short Custom Script.  Try 
> something like this:  (and select "run at the end of loggin process"):
>
>
> var url = "http://mylogprog.xxx?";
> url += "&title=" + sloggerGetVar("title");
> url += "&url=" + sloggerGetVar("url");
> url = encodeURI(url);
> // alert(url);
>
> var req = new XMLHttpRequest();
> req.open('GET', url, true);
> req.send(null);
>
>
> The first, construct the URL you want with sloggerGetVar() and 
> encodeURI().  Uncomment the 'alert' call to debug.  To make the 
> request, you can use XMLHttpRequest.  I think the above should 
> basically work, but I haven't tried this.
>
> Handling the GET responses would be more complicated.  See,
> http://developer.mozilla.org/en/docs/XMLHttpRequest
>
> good luck,
> Ken
>
>



More information about the Slogger mailing list