Archive for March, 2014

How To Fix TweetSharp After Recent Twitter Changes

Three days ago, I was contacted by a Tile Me! user telling me that the Twitter integration in the app did not work for him. I checked on my phone, everything was fine. I could also see other people were using it just fine too. So, I gave the default instructions of “Have you tried reinstalling the app?"’ which did not help 😦 .

Yesterday, I gave the user an account name and password that I control for app testing, just to see if the problem is with the app or the account he is trying to log in with. Lo and behold it works, while his accounts (yes he created several) don’t. That doesn’t make sense, does it?

After this, I decided to create a new Twitter account myself and test with that. Of course it does not work. I got in touch with Robert Shurbet and Sébastien Lachance who are both using TweetSharp in their apps. Robert said that he encountered this error before and he coded the authentication with a RestClient himself, while Sébastien was not aware of this issue which caused his app to crash altogether. The guy user that first reported this problem had created his Twitter account in February 2014. So, this problem might have been there for a while.

If you are using TweetSharp 2.3.0 (which is the stable version) or a modified 2.3.1, try creating a new Twitter account and see if you can log-in with it. If you can’t, read on.

The Problem

I noticed that the problem was with the access tokens. For some reason, TweetSharp  was returning a ‘null’ access token when I logged in with a newly created Twitter account. I examined the TwitterResponse object which at first glance seemed fine. The status said ‘OK’. But, clearly it was not OK. After digging some more, I found out that an inner exception had occurred during the processing of the access token and was logged in the TwitterResponse object.

The exception that was logged said something along the lines of “Value assigned is greater than Int32’. I thought that must be it. They probably changed the type of something from’ ‘int’ to ‘long’. To investigate further, I had to download the TweetSharp 2.3.0 source code.

Now that I could access the TweetSharp classes, I found out that the culprit was the ‘UserId’ in the OAuthAccessToken class.

The Solution

The solution was quite simple. Change the ‘UserId’ type from ‘int’ to ‘long’ and find what else I broke by doing that. After building the project, I got a few errors at a few lines in the TwitterService.OAuth.cs class where the ‘UserId’ property was used.

In order to fix the errors all I had to do was replace all the occurrences of:

UserId = Convert.ToInt32(query["user_id"] ?? "0"),

 

with:

UserId = Convert.ToInt64(query["user_id"] ?? "0"),

 

I built the project, replaced the .DLL that I was using from nuget with the newly compiled one, and voila everything was fixed. I also sent the .DLL to Sébastien which reported that the problem was fixed in his app as well.

If you want to edit the things yourself, download the source code and do the changes above. If you are lazy to do that, don’t worry, you can download the Windows Phone 8 .DLL I compiled from here. If you installed TweetSharp from nuget, just navigate to your project directory –> Packages –> TweetSharp.2.3.0 –> lib –> sl4-wp and replace TweetSharp.WindowsPhone.dll 

If you are using TweetSharp for WP7 or another platform, you’ll have to do the changes yourself (it’s the same ones).

Note: The developer has stopped supporting TweetSharp, so if you are creating a new app, use another alternative instead. I cannot guarantee that TweetSharp won’t break again anytime soon.  I heard Linq2Twitter is currently popular among developers.

Promote Your Windows Phone Apps With Device Shot

Few months ago, when I added a Twitter Background creator to Tile Me! I got this idea to create an app that would quickly generate in-device shots from your images. At that time, I thought it could be used by ordinary Windows Phone users to share their home screens. But, after talking to Robert Shurbet (the developer of #Hashtastic who I collaborated with to add the Avatar Gallery feature) I realized this kind of app would be great for developers to promote their apps on social networks too.

About two weeks ago I started implementing the idea and had a closed beta with few other developers who really contributed with the design choices. I’d like to thank Sébastien Lachance, Robert Shurbet, Hermit Dave and Mark Tepper. Special shout out to my brother Alpay for all the phone renders he managed to find and edit on the interwebs, the app wouldn’t exist without him.

Device Shot went live two days ago and was well received by many Windows Phone users. WPCentral published an article too! Along with App Promo by Sébastien Lachance, I believe they are currently the two best apps for developers to promote their own apps. On the left you can see an image generated with Device Shot for Rob Irving’s Car Dash.

I already submitted an update which is under certification to add support for Landscape images/screenshots too.

You can get Device Shot by scanning the QR code below. The trial version let’s you save up to 3 images. To remove that limitation you can purchase it for $0.99.