OAuthcalypse Now: Tweeting with Twitter, OAuth and Django

The Twitter OAuthcalypse hit me last week. Back in July, I used Twitter’s basic authentication scheme in a new site I’m working on (wantbox.com) to easily send out tweets via my @wantbox account whenever someone posted a new “want” to the site.

This integration took about 30 minutes to research and implement. All I had to do was put my twitter username and password in my Django project’s settings.py file, pip install the python-twitter app into my virtualenv and then use:

from django.conf import settings
import twitter
api = twitter.Api(username=settings.TWITTER_USERNAME, password=settings.TWITTER_PASSWORD)
api.PostUpdate('Someone in 02481 wants "a home gym" %s' % extra_stuff)

The resulting tweet would appear in my @wantbox stream appearing to come “via API”. Easy-peasy.

Continue reading »