Mobile Python: Rapid Prototyping of Applications on the Mobile Platform
by Jürgen Scheible, Ville Tuulos
9.1. Basic Principles
You can think of a web service as an ordinary Python module whose functions are just called in a particular way using urllib. As with ordinary modules, you have to see the API documentation to understand how to use the related functions. However, whereas the API of an ordinary Python module stays constant, even in different versions of Python, a web service provider may change the web API any time without prior notice. Because of this, we focus mostly on the basic principles of the Web service usage here, instead of explaining the current web APIs in detail.
To use a web service, you typically have to go through the following steps:
Go to the service provider's website and find the web API or developer documentation. Some well-known web APIs can be found at following addresses:
Amazon: http://aws.amazon.com
Flickr: www.flickr.com/services/api
Google: http://code.google.com/apis
Find documentation for the functionality you need.
Find out which protocol the service uses on top of HTTP. Many services support several different protocols. The most typical alternatives are JSON, XML or plain HTTP. Some services even provide a custom module for Python that hides requests to the web service behind normal Python function calls. However, some of these modules use new features of Python which are not yet supported by Python for S60.
Find out what kind of input data and parameters the service expects and how the output looks.
Add a function ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access