Interfacing with web services - advice needed

Bernard Devlin bdrunrev at gmail.com
Mon Mar 16 15:07:08 EDT 2015


Hi Graham

Interfacing with a website as you describe may be very easy.  However, if
you anticipate making scores or thousands of queries a day, they may block
your app (e.g. based on the User-Agent header sent along with your query).

Assuming you don't face that problem, then if the website just takes a URL
with parameters, you can simply use "get url" and construct the relevant
query, e.g. if the url in your browser is:

http://somegpssite.com/query.htm?lat=33.33&lon=66.66

you can produce this yourself thus:

put merge("http://somegpssite.com/query.htm?lat=[[tLat]]&lon=[[tLon]]")
into tURL
get tURL

Apart from error handling once you've initiated such a query, I don't think
it could be any easier than this.

If the website does not take a HTTP GET query, i.e. it uses a POST query,
then you will need to look at the FORM object inside the HTML source of the
web page where you initiate the query.  You will need to send a form to the
website to initiate the query.

I would have directed you to the Livecode online documentation, but in
their enthusiasm for v8, they have removed the old documentation from the
internet without putting up the new docs.  You can find the old version
through Google's cache:
http://webcache.googleusercontent.com/search?q=cache:n3TMFxFqBfAJ:docs.runrev.com/Function/libUrlFormData+&cd=1&hl=en&ct=clnk&gl=uk
Or you can look up libUrlFormData in the dictionary.

Once you have the relevant page returned from the site, then you need to
extract the data you want from the HTML.

A service with an API would probably be cleaner.  But I'd imagine they
would expect payment for multiple queries to their service.

Regards

Bernard


On Mon, Mar 16, 2015 at 5:37 PM, Graham Samuel <livfoss at mac.com> wrote:

> If I wanted to do this calculation personally as a one-off, I would go to
> one of a number of web sites that provide the calculation as a service, put
> in my parameters and read off the result. Simple. Now I want to do the same
> thing repetitively from within a LiveCode program. So I need a way to
> ’talk’ to one of these web sites as if I was keying information in and
> reading it out - I’m not expecting any special privileges like being given
> an more machine-oriented API to work with. So the question is, how would I
> go about coding this type of interaction? Has anyone done this recently?
> Are there any tutorials? I must say I find it very daunting, and would love
> to be told "it’s really quite easy”. Could be widget material, but I’m
> getting ahead of myself.
>
>



More information about the use-livecode mailing list