7

I've been looking for a solution to post to twitter from a wp7 app but have found very limited resources on the matter. Everything seems to be in either a different programming language (ex. PHP) or platform (ASP.NET), or is lacking documentation.

These questions did NOT work for WP7:

Post in Twitter using C# application

Twitter post API C#

Post Tweets to Twitter from FaceBook using ASP.Net C#

Are there any resources, code samples or posts that talk about how to get started with the Twitter API for WP7?

Also are there any particular libraries maybe that are well documented that support WP7?

Thanks.

Community
  • 1
  • 1
Edward
  • 7,346
  • 8
  • 62
  • 123
  • isn't Twitter using REST? Programming language shouldn't be a limitation if Twitter API is done with REST. Also, try searching www.codeplex.com. – codingbear Mar 03 '11 at 00:51
  • Yes, how do you accomplish this though? Twitter was very limited on examples. Also I've tried different libraries to help deal with this and most don't support wp7. Any suggestions on where to get started? – Edward Mar 03 '11 at 00:56

3 Answers3

7

One popular Twitter library for .Net is TweetSharp. They have a Windows Phone 7 compatible library they have a section which shows sample code for Windows Phone 7. The sample shows how to use the TweetSharp library to retrieve your mentions and post a sample tweet.

If TweetSharp isn't right for you check out the Twitter Libraries page .NET section on the Twitter Developers site for another library with Windows Phone compatablity.

bragboy
  • 34,892
  • 30
  • 114
  • 171
Adrian Clark
  • 12,449
  • 5
  • 36
  • 42
6

There are a couple of complete twitter apps on codeplex

I think both of these also have some associated blogging/documentation which might help - e.g. http://samjarawan.blogspot.com/2010/10/building-real-windows-phone-twitter-app_07.html

Stuart
  • 66,722
  • 7
  • 114
  • 165
  • These links are great! Exactly what I was looking for. The post is detailed and sample works great. – Edward Mar 03 '11 at 22:51
1

The fastest and easiest way is to use Twitter's Tweet Button API. This will make the user leave the page but allows them to modify the tweet how they like. You might be able to make this a little cleaner by embedding a WebBrowser item in your form and making it visible on tweeting.

Here is the code I use:

public class ShareTwitter
{
    // DOCS: http://dev.twitter.com/pages/tweet_button

    private const string URL = "http://twitter.com/share?url={0}&via={1}&text={2}";

    public static void Open(string link, string via, string text)
    {
        WebBrowserTask t = new WebBrowserTask();
        t.URL = String.Format(URL, HttpUtility.UrlEncode(link), HttpUtility.UrlEncode(via), HttpUtility.UrlEncode(text));
        t.Show();
    }
}

I have similar classes for Facebook, ReadItLater and the Windows Phone email - let me know if you're interested in that also.

AussieNick
  • 83
  • 5