Twitter API
Twitter is a little vague in terms of how you could make your first ‘hello world’ post, that’s why I am writing this post for your convenient.
If you, like me, always like to write a python script with Requests library on the spot just to quick-test some new APIs you encountered, you could be, just like me, puzzled by Twitter API’s authentication. Thanks to this dude ’s hint, I finally made a successful Twitter post (a tweet) through my what was supposed to be simple python script.
So you should realize that there is OAuth1 function in Requests that
helps you encode all the authorization parameters. And it seems like
Twitter only takes that for a successful authorization. otherwise you
get a 400 error saying not valid authorization :(
Of course, prior to make this call, you need to create/register your
Twitter app at their developer page, and set app’s authorization to both
read AND write. then, you could generate your token and secret. Be sure
to generate token AFTER you set app’s authorization :D Once you have all
consumer_secret, consumer_key, oauth_token, and oauth_token_secret,
you are set to go! Cheers!!!
Comments
comments powered by Disqus