开发者

Facebook C# SDK: Traverse The JsonArray To Get The Value of Tracking Data

This is a followup to:

(OAuthException) (#15) The method you are calling must be called with an app secret signed session

C# equivalent of file_get_contents (PHP)

Facebook API: Can I Invite A Test User To My Application?

So I'm at the final step now. I managed to invite users and get the request info once the invited user accepts the invitation. Now I need to traverse the result object (JsonArray) and get the value of the data field which is the tracking data that is sent with the Request Dialog

I've tried using dot syntax to traverse the object and some other things but I couldn't get it. So here's my code (which doesn't work):

        dynamic requestInfo = fb.Get("/me/apprequests/");
        if (requestInfo.data.Count > 0)
        {
            //var c = requestInfo.data.data;
            var a = requestInfo[0]["data"];
            ViewData.Add("TrackingData", "the value");
        }

And here's the result:

{"data":[{"id":"1001200425907","application":{"name":"MyFirstTestApp","id":"193005690721590"},"to":{"name":"Margaret Diibjcfhg

Sadansteinskymanbergwitz","id":"499203687"},"from":{"name":"Nancy 开发者_如何学编程 Diibjcfhf

Changwitz","id":"499203686"},"data":"someCode","message":"Invitation to the test application!","created_time":"2011-05-

18T09:31:40+0000"}]}


The data you are looking for is in requestInfo["data"][0]["data"] I used the JSONView addon for Firefox to help me traverse the structure to give you the answer, and I recommend it to help you figure out stuff like this in the future.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜