On the Weekend, Gary Jones from BlueFur (Twitter: bluefur) came up with the idea of a Twitter robot that would act as a Magic 8 Ball. He asked me if I wanted to help make it, I accepted, and development began.
What we came up with was a small script that would automatically reply with a Magic 8 Ball-type answer when it was “replied” to. To use it, all you have to do is write a “tweet” replying to magic_8ball with a yes or no question. Which would look like this “@magic_8ball <yes or no question>”.
This little “Twitter Bot” uses the Twitter API to receive the replies to it, and then send out replies with a randomly selected answer. We quickly found out that the Twitter API is quite restrictive. As outlined in Gary’s post, Twitter only allows 70 authenticated API requests an hour, which not only inconveniences developers while testing their Apps, but also users using Twitter Apps. Also, Twitter restricts API calls for replies and such to the latest 20, which can create quite a few problems.
We’ve decided to make this application Open Source, so that other developers looking to develop with the Twitter API can hopefully learn from our code. Feel feel to use, modify, hack and learn from this code to create your own Twitter Applications. The code is release under the GNU General Public License version 3 (or, at your option, any later version). You can get the code here (or in txt format here).
If you have any questions about the code, feel free to let me know.
I’m on Twitter under mattfreedman, feel free to follow me.