How do I read a public twitter feed using .Net

Posted by Jeff Weber on Stack Overflow See other posts from Stack Overflow or by Jeff Weber
Published on 2011-01-01T20:44:17Z Indexed on 2011/01/01 20:54 UTC
Read the original article Hit count: 257

Filed under:
|
|
|
|

I'm trying to read the public twitter status of a user so I can display it in my Windows Phone application.

I'm using Scott Gu's example: http://weblogs.asp.net/scottgu/archive/2010/03/18/building-a-windows-phone-7-twitter-application-using-silverlight.aspx

When my code comes back from the async call, I get a "System.Security.SecurityException" as soon as I try to use the e.Result.

I know my uri is correct because I can plop it in the browser and get good results.

Here is my relavent code:

    public void LoadNewsLine()
    {
        WebClient twitter = new WebClient();

        twitter.DownloadStringCompleted += new DownloadStringCompletedEventHandler(twitter_DownloadStringCompleted);
        twitter.DownloadStringAsync(new Uri("http://api.twitter.com/1/statuses/user_timeline.xml?screen_name=krashlander"));          
    }

    void twitter_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
    {
        XElement xmlTweets = XElement.Parse(e.Result); //exception thrown here!

        var message = from tweet in xmlTweets.Descendants("status")
                      select tweet.Element("text").Value;

       //Set message and tell UI to update.
       //NewsLine = message.ToString(); 
       //RaisePropertyChanged("NewsLine");
    }

Any ideas anyone?

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET