These notes discuss how a program on one server can access a program on another server through an application programmer interface (APIs). They are related to another document, The Web is Your Database, which focuses on RSS and Yahoo Pipes. This article focuses on accessing the Twitter API from an Android Application.
Web service: a software system designed to support interoperable machine-to-machine interaction over a network (wikipedia)
Example Twitter API command returns the global timeline in RSS:
This command returns a particular person's friend timeline:
Sample Client program mashing stock quotes with twitter:http://www.devx.com/webdev/Article/40511/0/page/1
When the stocks rise past a certain point, this program makes a twitter call.
Here's the code for the client program that uses the Twitter API and a Yahoo API that gets stock quotes:
Here's the way it works:
An API like Twitters can also be used to "port" service to a different device, e.g. the Android phone:
The Android system design requires that Applications always be ready to respond to external events within a few seconds. So instead of just waiting after making a Web request, the Twitter component sends its request and returns right away, but arranges for an event to be signaled when the result is ready. from google tutorial
Here's some program blocks that make use of two request/handle event sequences:
In these blocks, we first make a Login request to Twitter. While this interaction is occurring, the program could handle other user or external events. When Twitter logs the user in, the IsLoggedIn event occurs. At that point, the program issues a RequestFriendTimeline. Once again the program can handle events while Twitter is doing its job. When Twitter returns the timeline, the FriendTimelineReceived event occurs, and the program can process it (display the information).
1. Create a portfolio page "Twitter" where you'll document this lab.
2. If you don't have a Twitter account, register and get one. If you have one already, you may want to register with another account for the tutorials we'll be doing. Add a link to your Twitter account page on the portfolio page.
3. Add at least one status message on the account, and follow at least one person and get at least one person to follow you.
4. Answer the following questions on your Twitter portfolio page: a. How is twitter different than facebook? b. How is Twitter different than a blog? A blog reader?
5. On your phone, download an Android Twitter client and post a status message from it. What features does the Twitter Client you chose provide? Provide a screenshot of your Twitter Client and a description of its features on your Twitter portfolio page.
6. Now create a Twitter Client of your own using App Inventor. Complete Google's twitter demo tutorial
7. Write an Android application that combines texting and twitting. For instance, write an app. that texts your friend when you've added a new status message on Twitter (you could be at a computer adding the message but if your app is running it will see it and text it to your friend). You don't have to do exactly this-- be creative!