UPDATE 2012/04/13: check out this great post of ‘Depechie’ about using TweetSharp and the TwitterSearchStatus object together with AgFx.
I like to add a Twitter feed to the “About” page in my Windows Phone apps. This way I can inform the users about the latest updates through my twitter account.
Why re-invent the wheel when you can use existing libraries? I used Tweetsharp and AgFx data caching library.
I use AgFx so I can display the previous retrieved (cached) Twitter feed while it’s loading the new one. A common concept you see in almost any ‘news’ app.
I would like to share my implementation (code) which also includes a small work-around to make TweetSharp work with AgFx.
I think the code is pretty much self-explanatory but here are some pointers:
Installing TweetSharp through NuGet
Execute the following command in your NuGet Package Manager Console:
Install-Package -IgnoreDependencies TweetSharp
This will make sure the library installs successfully. Installing it through the normal method won’t work because the Hammock library is not yet updated to Windows Phone 7.1 (Mango) and will cause a roll-back of your installation.
Add your own Twitter OAuth key
Update the fields ‘Consumerkey’ and ‘Consumersecret’ in the class TwitterLoadRequest (TwitterFeed.cs)
private const string Consumerkey = "yourconsumerkey";
private const string Consumersecret = "yourconsumersecret";
Extension of Tweetsharp library
When writing this code the TwitterEntity object of the TweetSharp library didn’t support serialization. Serialization is neccessary for it to work with AgFx. This is why I introduced the additional classes MyTwitterEntity and MyTwitterUrl.
Tweet.cs
Each separate tweet is loaded into this object.
AgFx supporting classes
The classes TwitterFeed, TwitterDataLoader and TwitterLoadContext are supporting classes for the AgFx framework. They make sure the data is loaded and automatically cached. The caching policy is defined through an attribute on the TwitterFeed class named “CachePolicy”. More information on this can be found on the AgFx website.
TweetStatusConverter
The TweetStatusConverter uses the TweetEntity information to highlight the URL’s in tweets and make them available als links that you can click. It uses the OpenWebBrowserCommand class to open a webbrowser when the link is clicked.
Great!!
But when I run the project, “ArgumentException” always occurs on “InitializeComponent” of “App.g.i.cs” which was created by system tool automaticly.
Anybody has the same problem? How can I fix it?
Thanks!
Can you be more specific ? could you give the stacktrace ?
Well, I catch the screen photo here:
http://www.flickr.com/photos/79884164@N04/7005542548/
Hi, sorry for the late reply. Not sure what is going on. Did you already completely clean the solution and rebuild ? I think it might have to do with the localization, but not sure why. The project is working for me and other people, so it should work for you too.