【发布时间】:2014-05-08 10:35:36
【问题描述】:
这就是我所尝试的。
void APICallback(FBResult result)
{
Debug.Log("APICallback");
if (result.Error != null)
{
Debug.LogError(result.Error);
FB.API("/me?fields=id,first_name,friends.limit(100).fields(first_name,picture)", Facebook.HttpMethod.GET, APICallback);
return;
}
profile = Util.DeserializeJSONProfile(result.Text);
Name = profile["first_name"];
friends = Util.DeserializeJSONFriends(result.Text);
Debug.Log (Name);
foreach (object friend in friends) {
Dictionary<string, object> friendData = friend as Dictionary<string, object>;
foreach(KeyValuePair<string, object> keyval in friendData)
{
Debug.Log(keyval.Key + " : " + keyval.Value.ToString());
}
Dictionary<string, object> pictureData = Facebook.MiniJSON.Json.Deserialize(friendData["picture"].ToString()) as Dictionary<string, object>;
Dictionary<string, object> pic = pictureData["data"] as Dictionary<string, object>;
Debug.Log(pic["url"].ToString());
}
}
它给了我朋友的名字和 id,但我也需要图片,上面的查询在 fb api 图形浏览器上运行良好,并给出了图片的 url,但在统一时它不起作用。如果有人可以请帮助。谢谢
【问题讨论】:
-
你能在问题中包含你得到的确切结果吗?
-
Debug.Log(keyval.Key + " : " + keyval.Value.ToString());这给了我 id: 786453, name: Rehman 我也需要图片。
-
但这只是您处理结果的方法。你首先在哪里发送请求?可能你只是在这里修改了请求,在哪里重复,每次发送第一个请求时忘记包含图片参数?
标签: c# facebook facebook-graph-api unity3d