简体   繁体   中英

How to get newsfeed from facebook using c# SDK

I have the following method to retrieve feeds from my profile. The main problem is, I am not sure how to extract the feeds from the variable i got.

    private void RetrieveMyFeedsFromFacebook()
    {
        var fb = new FacebookClient(_accessToken);
        string details = "";
        try
        {
            fb.GetCompleted +=
            (o, e) =>
            {
                if (e.Error == null)
                {
                    var result = (IDictionary<string, object>)e.GetResultData();
                    //Dispatcher.BeginInvoke(() => lbFeeds.ItemsSource = details);
                }
                else
                {
                    Dispatcher.BeginInvoke(() => MessageBox.Show(e.Error.Message));
                }
            };
            fb.GetAsync("/me/feed");
        }
        catch (FacebookApiException ex)
        {
            MessageBox.Show(ex.Message);
        }
    }

From googling, it looks like the response you get is most likley in JSON format. See the following blog post:

http://facebooksdk.blogspot.com/2011/05/facebook-status.html

Anyhow, if your above code works, but you are not sure of the response format. Why not just add a breakpoint and explore the returned event argumenst from within visual studio?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM