我正在使用一个名为 prime[31] 社交网络插件的统一插件来处理 Facebook。它适用于这样的事情:
void onGraph()
{
Facebook.instance.graphRequest( "me", HTTPVerb.GET, ( error, obj ) =>
{
// if we have an error we dont proceed any further
if( error != null )
return;
if( obj == null )
return;
// grab the userId and persist it for later use
var ht = obj as Dictionary<string,object>;
_userId = ht["id"].ToString();
Debug.Log( "me Graph Request finished: " + _userId );
Prime31.Utils.logObject( ht );
} );
}
它返回这个:
--------- IDictionary ---------
id: ##########
name: Mike O'Connor
first_name: Mike
last_name: O'Connor
link: https://www.facebook.com/##########
username: ##########
etc...
而且我似乎可以抓住任何键并将其填充到这样的变量中,对吗?:
_userId = ht["id"].ToString();
但是当我要求每个人玩我的游戏的分数时:?
void onGetScore()
{
Facebook.instance.graphRequest( "AppID/scores", HTTPVerb.GET, ( error, obj ) =>
{
// if we have an error we dont proceed any further
if( error != null )
return;
if( obj == null )
return;
// grab the userId and persist it for later use
var ht = obj as Dictionary<string, object>;
_score = ht["score"].ToString();
Prime31.Utils.logObject( ht );
} );
}
它返回一个嵌套字典/列表,如下所示:
--------- IDictionary ---------
--------- IList ---------
data:
--------- IDictionary ---------
user: --------- IDictionary ---------
name: Mike O'Connor
id: ##########
score: 5677
application: --------- IDictionary ---------
name: ##########
namespace: ##########
id: ##########
现在它是嵌套的,所以我不能使用它,对吧?
_score = ht["score"].ToString();
如何获取嵌套键?这只是语法问题还是我必须重铸(或其他)?