Twitter API
Twitter API is REST API(Representational state transfer api) and it outputs a json file which is faster than traditional xml data transfer method. By using Twitter API we can access some of the elements that tweet contains tweet,author name,tweeted time etc, all these things are encoded in json file.
In order to connect to twitter API you need to have a Twitter account and for developers you can register from right here https://apps.twitter.com/ and create a new app
After that you will be provided 2 keys those are consumer key and access key. This authentication method is called OAuth authentication
Using of OAuth autentication provide following benifits
After using tweepy we can handle the authentication process as follows After that you can get the twitters from the api. After that you will be provided 2 keys those are consumer key and access key. This authentication method is called OAuth authentication
Using of OAuth autentication provide following benifits
- Tweets can be customized to have a string which identifies the app which was used.
- It doesn’t reveal user password, making it more secure.
- It's easier to manage the permissions, for example a set of tokens and keys can be generated that only allows reading from the timelines, so in case someone obtains those credentials, he/she won’t be able to write or send direct messages, minimizing the risk.
- The application doesn't reply on a password, so even if the user changes it, the application will still work.
Representation of data
above shows a sample json file from the twitter API
after getting from the api we can simply get that from the tweepy cursor.
above code will store the cursor value in a python Dictionary.
References
http://www.tweepy.org/