Operation TweetToTayTay

So a few months ago it was coming up to my girlfriends birthday (lets call her R) and I decided to do something different for a present for her. Her favorite artist is Taylor Swift so I figured I'd try tweet to her to try get a birthday message, but then I thought why don't I go one better, and try to get her to come to the party.

I have a spare media PC sitting in my lounged so I figured it'd be a perfect platform for this bot to run on. I then had to figure out what language I wanted to use. I looked into PHP first as I knew Twitter had its own API and I could use cURL to access twitters API. After fiddling with this for a while I realized I didn't exactly know what I'd do to make the script run at a designated time so I started looking into a C# based system.

After looking at quite a few different libraries I settled on Twitterizer for no particular reason other than in a quick prototype it was quite easy to set up. During this I had to head over to developer.twitter.com/apps to create the TweetToTayTay app. In the app settings you can get 4 different strings you need to put in the source code listed below. An oauth_token, oauth_token_secret, oauth_consumer_key and oauth_consumer_secret. This allows us to authenticate our twitter app to access twitter as our twitter user. In this case I created an account called taylorplsrespnd. The reason its "respnd" not "respond" is because of Twitters username length restrictions. I also set up a display picture, cover photo and bio which describes a little bit more of what I am doing and why. It also links to taytay.4pi.com.au which is a count down to when R will be seeing Taylor Swift in concert, another present I got her for her birthday.

Next step was to send out a tweet. The sample code listed in the github repo for Twitterizer was as follows.

var response = TwitterStatus.Update(credentials, "Twitterizer is fantastic!");

When I eventually figured out what the credentials value was I kept getting an error sending the tweet. I knew that statuses/update was the Twitter API call to update a status so I looked into that. After a bunch of mucking around I eventually noticed that Twitter was wanting to use API version 1.1. I forget how but I found that Twitterizer was using 1.0. I found that there is a third parameter of TwitterStatus.Update which allows me to pass a StatusUpdateOptions object in. I was able to use this in the following way:

StatusUpdateOptions options = new StatusUpdateOptions(); options.APIBaseAddress = "https://api.twitter.com/1.1/";

After I did this I was able to send a tweet successfully.

A basic way I'd like to set up TweetToTayTay to run in a loop, generate a message, send it, go to sleep for 15 minutes, rinse and repeat. One thing I found during testing is if you try send to tweets of the same text in a row Twitter will error. A way around this was to mix up the message being sent. I settled on a basic message structure of [

Note: It appears the rest of this post was lost in a backup and restore some time ago.