Say you're browsing books at your favorite bookstore and want to know how much a book costs at Amazon. Amazon at the Bookstore, the app described here, lets you search Amazon by keyword or ISBN number, and find the lowest price of the books you find. You can even scan a book's QR code to automatically trigger the search. Want to try it? Just scan the QR code to the right with your Android phone -->
Amazon at the Bookstore demonstrates how App Inventor can be used to create apps that talk to web services (APIs). It's a client app that gets data from a web service that already exists, specifically http://appinventoramazonlist.appspot.com. After stepping through this tutorial you'll be able to create your own custom client app for talking to Amazon. For those of you that know some Python programming, or a Python programmer, you can also build your own App-Inventor-compliant web services, which can then be consumed by App Inventor clients. One way to start is to download the source code of http://appinventoramazonlist.appspot.com and modify it to call the web service you want. Creating the Amazon Client with App Inventor Components Here is how the app looks in the Component Designer after the necessary components are added: The key non-visual component is TinyWebDB, which is found in the "not ready for prime time" drawer. When you drag this component into the app, you can set the Service URL for it. In this case, set the URL to http://appinventoramazonlist.appspot.com. Designing the Behavior You access App-Inventor-compliant web services using the TinyWebDB component and its GetValue operation. GetValue requires an argument tag that can be used to ask for particular data from a service. All services will return data in a particular format. http://appinventoramazonlist.appspot.com uses the following protocol:
The list returned is a list of books, with each item (book) being a list itself with the following items: item 1: title
item 2: cost item 3: isbn Here are the blocks for the app: Details on how they work to come... The Amazon TinyWebDb Web Service The App Inventor team provided the original tinywebdb web service (http://appinvtinywebdb.appspot.com/) as a model for other web services that can be "consumed" by Android clients using the TinyWebDB component. The service was implemented using Google's App Engine and the Python programming language. It doesn't call another web service, but instead allows you to store and retrieve persisten data. The Amazon web service used in this demo, http://appinventoramazonlist.appspot.com., was built by modifying the original web service so that it gets its data not from a database but from Amazon. You can download the source code for it here. The code won't work out of the box, you'll need to get an account with Amazon web services and plug your authentication keys in. Challenge
|