Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Read RSS Feeds from a Facebook Page On Windows Phone

0.00/5 (No votes)
7 Feb 2013 1  
Simple example of reading RSS feeds from Facebook page using Syndication Library

Introduction

I was searching for a way to keep in touch with my WP application users, and I've just figured out that the best way is to push my updates from my Facebook page, right to their WP screen. And it works fine. Maybe you'll even think of other useful things to do with this solution.

Using the Code

https://graph.facebook.com/PageName

This is the main screen (note the page's title):

And this is the RSS feeds after tapping the get RSS button:

  • The code is so simple and consists of two main parts: The response handler function where the dispatcher begins the invoking, and the other is the code of the button where the initiation of the request begins and calls it.

    Here is the code of the response handler:

    HttpWebRequest request = (HttpWebRequest)asyncResult.AsyncState;
    
    HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(asyncResult);
    
    if (response.StatusCode == HttpStatusCode.OK)
    {
        XmlReader reader = XmlReader.Create(response.GetResponseStream());
        SyndicationFeed newFeed = SyndicationFeed.Load(reader);
    
                        
        Dispatcher.BeginInvoke(() =>
        {
            this.PageTitle.Text = newFeed.Title.Text;
            foreach (SyndicationItem sItem in newFeed.Items)
            {
                listBox1.Items.Add(sItem.Title.Text);
            }
        });
    }

Points of Interest

In the response handler, don't add any code above the Dispatcher.Invoke() or it will raise an exception.

History

Don't be shy.. if there are any questions, please feel free to ask.. or inbox your question here: facebook.com/amabualrub.

If you found this useful, please rate it.

Good luck & happy coding!

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here