我的代码在这里遇到问题,我现在正在谷歌搜索3个小时。
我正在做一个FQL查询,我正在尝试读取结果。但不幸的是。我不知道怎么做。
var fbclient = new FacebookClient(accessToken);
dynamic result = (IDictionary<string, object>)fbclient.Get("fql", new
{
q = new[]
{
"SELECT name FROM user WHERE uid = me()",
"SELECT unread_count FROM mailbox_folder WHERE folder_id = 4 AND viewer_id = me()",
"SELECT is_unread FROM notification WHERE recipient_id = me()",
"SELECT unread FROM friend_request WHERE uid_to = me()"
}
});
string name = "";
foreach (dynamic data in result.data)
{
name = data.name;
}
最后一部分(foreach
)无效 - 这只是我尝试的最后一件事。
答案 0 :(得分:1)
好。现在回答我自己的问题。花了一段时间,但我终于弄明白了如何从FQL-Multi-Query中获取信息。对于那些搜索相同的人:
dynamic result = fbclient.Get("fql", new
{
q = new[]
{
"SELECT unread_count FROM mailbox_folder WHERE folder_id = 0 AND viewer_id = me()",
"SELECT is_unread FROM notification WHERE recipient_id = me()",
"SELECT unread FROM friend_request WHERE uid_to = me()"
}
});
var unread_messages = result["data"][0]["fql_result_set"][0]["unread_count"];
var notifications = result["data"][1]["fql_result_set"];
var open_friendRequests = result["data"][2]["fql_result_set"];
这就是我所想要的; o)
致以最诚挚的问候,
丹尼