The Twitter API, Twython and I

Musical references aside my time has, since building as much of the actual system on breadboard as was needed and ordering PCBs, been spent mostly on finding a suitable Python 3 compatible Twitter library and getting it to work.

Job number 1 was finding one I liked the look of. Truth be told, this extended as far as some Googling and finding a list of popular libraries. Then choosing one that was actively maintained, worked with Python 3 and introduced the least interfering with data between me and the actual Twitter REST API 1.1.

The eventual winner was Twython (Twython@PyPiTwython@GitHub) it looked like it was everything we needed and only really just built requests and decoded responses from the API so it was nice, light and the official twitter documentation on the API was relevant to it too.

Actively maintained, pure Python wrapper for the Twitter API. Supports both normal and streaming Twitter APIs. – Twython GitHub page

If you keep an eye on the twitter account and the embedded twitter feed to the right of the blogs column you’ll be able to see bits of activity as more and more of the Twitter side code is written. At the moment a basic job queuing mechanism is being coded that will grab incoming mentions, see if the system has processed them by sending a  reply to them already and if it hasn’t queue them up to be replied to after it’s finished checking.

It’s fairly simple and much like an auto responder but it’s a building block. Next on the to-do list for it is to find a way to make each tweet unique as Twitter won’t allow the same tweet to occur twice even if it’s a unique response ID in response to a unique tweet ID. There might be something time related tied in here but we’ve not figured it out yet. Once that’s been solved there is mainly the task of designing a syntax for command and response tweets and then interpreting them to pass to the rest of the system.

…and then input scrubbing to catch invalid commands and some sort of  catch all system as if the mentions and responses fall out of sync it will cause problems for the current job queue generator.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s