I noticed this morning that Twitter have finally disabled a feature called "Basic Authentication" which allows you to easily post messages to Twitter.
Sound familiar? It should. We use it for posting Twitter messages in the code on Chapter 3.
But in the same way that eight-track tapes got replaced with these spiffy new "audio cassettes", Basic Authentication is now a thing of the past.
However, don't worry. We *have* found a workaround. Twitter is keen to keep your Tweet account as secure as possible and instead of using Basic Authentication, they are now using a newer system called "OAuth". OAuth is very cool, and very secure unfortunately it's... kind of tricky.
In fact it's been described as about as straightforward as performing brain surgery on a roller coaster.
Fortunately, there's a really useful guide on
that tells you how to enable OAuth for your application. There's quite a few steps and we will get a similar set of instructions out in the next few days, in a more Head First style, but it's a great place to start.
By the end you should be able to replace the code from the book with something like this:
CONSUMER_KEY = '...'
CONSUMER_SECRET = '...'
ACCESS_KEY = '...'
ACCESS_SECRET = '...'
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
api = tweepy.API(auth)
The CONSUMER_KEY, CONSUMER_SECRET, ACCESS_KEY and ACCESS_SECRET values need to need to some magic mojo that the above will tell you how to create.
If you drop the above code into your program in place of the send_to_twitter(msg) function in the book, you should find yourself back and Tweeting in no time.