开发者

Getting an empty Facebook news feed response using Facebook C# SDK

开发者 https://www.devze.com 2023-03-12 22:54 出处:网络
I am using the Facebook C# SDK in my Silverlight 4 browser app to perform some requests to the Facebook Graph API. I followed the example in the SDK documentation to request the user\'s information (u

I am using the Facebook C# SDK in my Silverlight 4 browser app to perform some requests to the Facebook Graph API. I followed the example in the SDK documentation to request the user's information (using the asynchronous method to make it work on Silverlight):

        var fb = new FacebookClient(accessToken);

        fb.GetAsync("/me");

        fb.GetCompleted += (o, ea) =>
        {
            var result = (JsonObject)ea.GetResultData();
            var name = (string)result["name"];
        };

This way I get the JsonObject without any problem and I can read all data, but when I make request to "me/feed" or "me/home" instead of "/me":

        fb.GetAsync("/me/home");

        fb.GetCompleted += (o, ea) =>
        {
            var result = (JsonObject开发者_如何转开发)ea.GetResultData();
            var data = (JsonArray) result["data"];

            foreach (JsonObject post in data)
            {
                id = (string)post["id"];

            }
        };

then the JsonObject is empty and I get a exception when trying to access its elements. I successfully managed to POST a message to "me/feed", but why do I receive an empty response when making a GET request? I have set the access token in the FacebookClient I'm using to make the calls, is there something else that I'm missing?

Thanks!

0

精彩评论

暂无评论...
验证码 换一张
取 消