Facebook C#SDK:遍历JsonArray获取跟踪数据的价值 [英] Facebook C# SDK: Traverse The JsonArray To Get The Value of Tracking Data
问题描述
这是一个跟进:
(OAuthException) (#15) The method you are calling must be called with an app secret signed session
相当于file_get_contents(PHP)的C# / a>
C# equivalent of file_get_contents (PHP)
Facebook API:我可以邀请一个测试用户到我的应用程序吗?
所以我现在是最后一步。邀请用户接受邀请后,我设法邀请用户并获取请求信息。现在我需要遍历结果对象(JsonArray),并获取数据字段的值,该字段是使用请求对话
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");
}
结果如下:
{data:[{id:1001200425907,application:{name:MyFirstTestApp,id:193005690721590} :{name:Margaret
Diibjcfhg
{"data":[{"id":"1001200425907","application":{"name":"MyFirstTestApp","id":"193005690721590"},"to":{"name":"Margaret Diibjcfhg
Sadansteinskymanbergwitz,id:499203687},from:{name Nancy
Diibjcfhf
Sadansteinskymanbergwitz","id":"499203687"},"from":{"name":"Nancy Diibjcfhf
Changwitz,id:499203686},data:someCode,message:
$ b应用程序!,created_time:2011-05 -
Changwitz","id":"499203686"},"data":"someCode","message":"Invitation to the test application!","created_time":"2011-05-
18T09:31:40 + 0000}]}
18T09:31:40+0000"}]}
推荐答案
您正在查找的数据在 requestInfo [data ] [0] [data]
我使用Firefox的JSONView插件来帮助我遍历结构来给出答案,我建议它帮助你在将来找出这样的东西。
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.
这篇关于Facebook C#SDK:遍历JsonArray获取跟踪数据的价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!