Budgie 3

Brian Dunnington recently sent me a pull request for Budgie, adding support for Windows Phone 8 and the ability to post images. Since accepting his changes and publishing them to Nuget, I've found myself somewhat reinvigorated when it comes to Budgie, and have embarked on a refactoring crusade. These changes will eventually see daylight as Budgie 3.0.0.

So what's (going to be) new in Budgie 3?

Removed .Net 4 Support

Budgie 3 will still be a Portable Class Library, but it will no longer support .Net 4 or any flavour of Silverlight. Supported platforms will be .Net 4.5, Windows Phone 8 and the Windows Store.

TwitterAuthenticator Class

I have split the methods for authenticating with Twitter off into their own class. TwitterClient, the class you would be used to using, now has an internal constructor and can only be created with the TwitterAuthenticator class. Here's some sample code:

var auth = new TwitterAuthenticator(new MyPlatformAdaptor(), consumerKey, consumerSecret);

// Authenticate with Twitter
var response = await auth.AuthenticateAsync(accessToken, accessSecret);

if (response.StatusCode != HttpStatusCode.OK)
{
    // could not authenticate!
    Console.WriteLine(response.ErrorMessage);
    return;
}

var client = response.Result; // this is our authenticated TwitterClient instance

Console.WriteLine(client.User.ScreenName); // each client is associated with a user

var homeResponse = await client.GetHomeTimelineAsync(); // same as always

As you can see, the TwitterClient class now has a User property representing the authenticated user. This should make it relatively easy to create a Twitter app that tracks multiple logins. If you've used the AuthenticateAsync overload that takes a request token (when you first authorize the app) the User instance will only have its Id and ScreenName properties populated. The VerifyCredentials method on TwitterClient will fully populate the User property in that case.

A Renamed Property

I've renamed ITwitterResponse<T>.Result to ITwitterResponse<T>.Content. This means that it'll be less confusing when you're working directly with Task<ITwitterResponse<T>> (which is what most of Budgie's public methods return), as before you would be asking for response.Result.Result.

It's handy to think of ITwitterResponse<T> as a strongly-typed HttpWebResponse, so Content makes much more sense as the property name.

Some New Dependencies

When I first created Budgie, I was a little concerned about taking too many dependencies on other Nuget packages, so the only package it depended on was Json.NET. Nowadays I'm a bit more relaxed about taking dependencies, so this one adds a few more. As well as Newtonsoft.Json (Json.NET), we now depend on Microsoft.Net.Http, which in turn brings with it Microsoft.Bcl and Microsoft.Bcl.Build.

When will Budgie 3 be released? Not sure yet. I want to run Halfwit on it locally for a while and make sure it's nice a stable. Keep an eye out on Twitter for progress reports!

budgie twitter .net
Posted by: Matt Hamilton
Last revised: 18 Apr, 2024 07:05 AM History

Comments

No comments yet. Be the first!

No new comments are allowed on this post.