So out of pure curiosity I started to think, how hard would it be to implement a twitter update for every new blog post that I do on this website? Turns out it's simplicity itself.

Start by logging in to the twitter developer site and create a new application by filling out all the necessary information in the "Create an application" form.

Secondly after the application has been added to your account, you need to create access tokens for the application. You do this on the application page with the button marked with "Create my access tokens".

From the application page copy the "Consumer key", "Consumer secret", "Access token" and the "Access token secret".

Now grab a copy of Linq2twitter either from their codeplex page or from the nuget repository and either create application settings as I've done below or just use the keys directly.

var auth = new SingleUserAuthorizer {
    Credentials = new InMemoryCredentials
    {
        ConsumerKey = ConfigurationManager.AppSettings["Twitter:ConsumerKey"],
        ConsumerSecret = ConfigurationManager.AppSettings["Twitter:ConsumerSecret"],
        AccessToken = ConfigurationManager.AppSettings["Twitter:AccessTokenSecret"],
        OAuthToken = ConfigurationManager.AppSettings["Twitter:AccessToken"]
    }
};

// Will throw exception if there are missing authentication
// settings.
auth.Authorize();

using (var context = new TwitterContext(auth))
{
    context.UpdateStatus("My awesome tweet");
}

As you run the code there should now be a new tweet on your twitter account!

Sources