Wednesday, April 7, 2010

The Learning Ramp for the Twitter API:Streaming API

The Streaming API is Twitter's third and most advanced API. The other two REST based API's do not give you real time access with its methods, but the streaming API gives you a constant real time flow of data. If you want data from the streaming API you only have to call it once, and the data will update itself as it needs too. Currently only non-protected public statuses are allowed to by used by the streaming API. The Streaming API also filters out low quality users, there is no result relevance all statues are passed through, and the authentication required is basic. There is no rate limit on the streaming API, but you are only allowed to make one connection to it. If you attempt to make multiple connections with the same IP address that can result in being banned from using the Twitter API.  The streaming API only works for json and xml, but Twitter strongly recommends that you use json for the streaming API. There are 5 ways to use the streaming API, and they can be seen here. The streaming API is really good for those apps that need real-time constant updates, for example if you needed up to the date information on a current happening in the world like the earthquake in Haiti.

Friday, April 2, 2010

Learning the Twitter API: OAuth

Anyone using the Twitter API these day seems to be having pain with the OAuth. Well what is OAuth, How does it work, and why does twitter want to switch over to OAuth? Well OAuth is an open form of authorization that allows you to share private resources from one website to another website without having to give your username and password. It works by giving out tokens of data, and each token gives access to a specific site for a specific resource. This way your username and password or not compromised. Think of it like going to a restaurant and giving your credit card to the waiter to charge, but your not giving him your pin number so he can go to an ATM and take all your money. Thats how OAuth works in a nutshell. Twitter wants to switch over to OAuth from Basic Auth because OAuth is much more secure. Twitter is even increasing the rate limit for OAuth users of their twitter api endpoint to 350 call per hour!

Thursday, April 1, 2010

The Learning Ramp for the Twitter API:REST API Methods.

The REST API method allows you to use all the core data from twitter, so the API's here let you do just about anything twitter does. The link is included for information on each of the methods which can be seen here. I will use an example using the user method for returning tweets about a specific user give their user id. To this you need the id of user you want to see. You can find how to find the id number by going here. I will be showing you how use this method to retweet a post from Jamie Oliver(The Naked Chef).

  • URL to use in your browser
    •  http://api.twitter.com/1/users/show.xml?user_id=1401881
  • Valid Formats
    • json
    • xml
  • The HTTP method is GET
  • The id for Jamie Oliver is 18676177
  • So now you simply do the following
    • http://api.twitter.com/1/users/show.xml?user_id=1867177
    • http://api.twitter.com/1/users/show.json?user_id=18676177
If do this in you Firefox web browser you should see the tweets made by Jamie Oliver. Of course you can use this in your app by placing it in your code. I will try and put up an example of this soon.