Working with Twitter API version 1.1

Twitter have migrated its API platform form version 1 to 1.1 which required authentication in order to access the data from twitter. Once you login to twitter using Oauth by supplying Api Key and Api Secret you will get a access token which use to make a authorized call to Twitter’s API.

Lets see how you can make your own Twitter API Library in Python using urllib2 and json library that call Twitter’s API Internally. Few steps we have to perform In order to get the Twitter’s API access.

Create a Apps

You have to create a Twitter App that will ask you few informations and generates the API and Secret Key. Visit https://apps.twitter.com and login with your twitter account.

Create a Twitter App

You can Test and generate the signature for the different services for Twitter OAuth API. you can get the list of API provided by Twitter from API Console.

Well It is not full updated, but provides a testing for different version such API 1 and API 1.1. Next thing after setting up an application is to Obtaining access tokens that will used to make an API request.

Obtaining access tokens

In order to make authorized calls to Twitter’s APIs, your application must first obtain an OAuth access token on behalf of a Twitter user or you could issue Application-only authenticated requests when user context is not required. The way you will obtain such tokens will depend on your use case. Get details if you want to access Twitter other then Application-only authentication method.

Get Favorite Tweet

Once you success with obtaining a token you can make call to any Twitter API. You need to get the correct service endpoint from where you can get the favorite list, as we have obtain token for Application-only authenticated requests it is not a user context we need to pass Screen name.