Twitter: Difference between revisions

no edit summary
imported>Konarkmodi
imported>Paulproteus
No edit summary
Line 24:
<pre>pip install httplib2 simplejson oauth2 python-twitter</pre>
 
=== Register a "Twitter application" on Twitter.com ===
The python-twitter library now only supports oAuth authentication as the Twitter devs have indicated that OAuth is the only method that will be supported moving forward. So make sure in order to use the Twitter App you have the following with you:
 
The python-twitter library now only supports oAuth authentication as the Twitter devs have indicated that OAuth is the only method that will be supported moving forward. So make sureyou in orderneed to useregister theas a Twitter Appdeveloper. youThis haveis thefairly followingeasy withand you:free of cost.
 
Registration Process:
* Log in to the Twitter Developerdeveloper Sitesite [https://dev.twitter.com/apps/new] with your regular Twitter username and password.
* Create a new Twitter application. For the fields, try these suggestions:
** '''Name''': My sample Twitter app
** '''Description''': My description
** '''Website''': https://openhatch.org/wiki/Twitter
** ''Callback URL''': (leave this blank)
** Now you can click to '''Create your Twitter application'''. You should proceed to the app information page.
 
 
(If you run into problems, take note: The website URL has to start with http or https. You don't need to specify Callback URL.)
 
Now, make the Twitter application able to post to your Twitter profile. To do that:
 
* Start at the app information page.
* Click on '''Settings'''.
* Scroll down to '''Application Type''' and choose '''Read, and Write'''.
* Click '''Update this Twitter application's settings'''.
 
 
Now, you need to permit yourself to use that app. To do that:
 
* Start at the app information page. (Make sure you are on the '''Details''' tab.)
* At the end of the page there is a button - "Create my Access Token" , click on this to generate the access_token_key and access_token_secret. Once you get the confirmation that your app's access tokens have been created you can go to the "OAuth tool" tab on the same page and all your app's credentials will be listed and are to be kept confidential.
* Write down the below credentials Twitter just created for your application (you'll need them later on): Consumer key Consumer secret
 
* consumer_key
* consumer_secret
* access_token_key
* access_token_secret
 
Registration Process:
* Log in to Twitter Developer Site [https://dev.twitter.com/apps/new] with your regular Twitter username and password.
* Create a new Twitter application. Few problems I faced during the registration: a)The website URL has to start with http:// b)You don't need to specify Callback URL. If you do any POST actions, you must set access to Read & Write.
* Write down the below credentials Twitter just created for your application (you'll need them later on): Consumer key Consumer secret
* At the end of the page there is a button - "Create my Access Token" , click on this to generate the access_token_key and access_token_secret. Once you get the confirmation that your app's access tokens have been created you can go to the "OAuth tool" tab on the same page and all your app's credentials will be listed and are to be kept confidential.
 
Once you have the above mentioned details, you can use the skeleton code shared below.
Anonymous user