[Zope] Http API Ping

Thomas B. Passin tpassin@mitretek.org
Wed, 10 Oct 2001 13:23:42 -0400


[Chris Withers]

> Brendon Grunewald wrote:
> >
> > I need to ping an external url, but do not want the customer to click a
> > submit button or something similar. i.e. if a certain page is viewed, I
want
> > to ping an HTTP API on another server in the following format:
> > "http://www.sp.com/api/@param=abc". Depending on the parameter sent to
them,
> > I either need to store the result returned or ignore it and carry on
> > regardless.
>
> Hmmm, try an external method something alogn the lines of:
>
> import urllib
>
> def ping(self):
>    return urllib.urlopen('http://www.sp.com/api/@param=abc').read()
>
> ...lemme know if it works :-)
>

Oh, that kind of thing works well, but you have to handle failure conditions
and time-outs in case the server isn't working or something.  Also, you
might not want everything to stop while you are waiting or the response.

Cheers,

Tom P