Javascript + FB.api获取FB页面列表

时间:2012-11-06 12:59:10

标签: javascript facebook json

我有一个从我的FB.api返回的Json对象,但我很难获取其中的数据组件,基本上我只需要'数字'中的'name'和'accesstoken',尝试了几种方法几个例子,但仍然无法得到它。任何人都可以帮忙。感谢。

if (response.authResponse) {
                    FB.api('/me/accounts', function (result) {
                        console.log(result);
                    });
                }

我可以从日志结果中看到来自firebug的数据:

data


[Object { name=

"Test Company"

,  access_token=

"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

,  category=

"Travel/leisure"

,  more...}, Object { name=

"Some Page"

,  access_token=

"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

,  category=

"Computers/technology"

,  more...}, Object { name=

"Something"

,  access_token=

"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

,  category=

"App page"

,  more...}, 40 more...]


paging
    Object { next=

"https://graph.facebook....fter_id=68468454846654"

}

1 个答案:

答案 0 :(得分:1)

您是否尝试过迭代数据?

for (i in data){
   console.log(data[i]);
   console.log(data[i].access_token);
}