简体   繁体   English

FB.API invitable_friends返回值

[英]FB.API invitable_friends return values

I am creating a custom UI panel for Facebook Invites on Unity for which I need all the names of the friends. 我正在为Unity上的Facebook邀请创建一个自定义UI面板,为此我需要所有朋友的名字。 This, I am trying to get to a Dictionary or any other data type. 这是我想获取的Dictionary或任何其他数据类型。 From the IResult object which I get from FB.API. 从我从FB.API获得的IResult对象。

The query I used is as follows: FB.API("/me/invitable_friends?fields=id,name",HttpMethod.GET,GetUserFriends); 我使用的查询如下:FB.API(“ / me / invitable_friends?fields = id,name”,HttpMethod.GET,GetUserFriends);

I get a Dictionary in the IResult object in which there is a key called "data" with all the friends stored in one object. 我在IResult对象中获得了一个Dictionary,其中有一个名为“数据”的键,所有朋友都存储在一个对象中。 My question is how do I get each of the friends into a Dictionary or any other type from the Object. 我的问题是如何使每个朋友进入字典或对象中的任何其他类型。

(PS. I am writing the code a in C# script) (PS。我在C#脚本中编写代码a)

Your IResult["data"] object is just of type object. 您的IResult [“ data”]对象只是类型的对象。

What you want to do is then cast that object to be a Dictionary; 然后您要做的就是将该对象转换为Dictionary;

(Dictionary<string, object>)result["data"]

The above (I don't know what you called your result variable sorry, so I just called it result) should work. 上面的(我不知道您叫您的结果变量对不起,所以我只是称它为结果)应该可以工作。

You'll then have to case each user again to a dictionary to get their information out in separate fields. 然后,您将不得不再次让每个用户使用字典,以在单独的字段中获取其信息。 Reading the documentation should help with finding out what fields the dictionary contains, or you can do a foreach loop and Debug.Log all of the dictionary keys. 阅读文档应该有助于找出字典包含的字段,或者您可以执行foreach循环和Debug。记录所有字典键。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM