Alex Rivera | Logout

Can someone provide a simple Python example for Twitter status updates?

Asked 2010-08-25T14:54:38.133
10

I'm having problems to find a simple python twitter oauth example which shows how to post a user status on Twitter. Could you help me?

Edit
Report

1 Answer

4

Here's an example that will get you authed with Twitter using rauth.

After that point all you'd have to do to update the authenticated user's status is:

r = session.post('statuses/update.json',
                 data={'status': 'Updating my status from the cmd line.'})
print r.json()

(You only need to care about the code up until you retrieve your authenticated session object, i.e. line 20.)

Hope this helps!

Edit

You will need to get your own consumer_key and consumer_secret for this to work because the rauth demo app does not have write permissions, for obvious reasons. So you'll end up with this response if you try to run the modified script without updating the credentials:

{u'request': u'/1/statuses/update.json', u'error': u'Read-only application cannot POST'}

Ensure your application is allowed to write and it should work as expected.

answered 2013-03-29T00:04:59.220

Your Answer