所以我试图从用户那里找到一些用户信息。但是,我只能得到那些在public_profile和"简单类型"比如first_name,gender等。但是,我无法获得age_range或user_relationships状态或当前位置。我正在使用该片段,
FB.api('/me', {fields: 'name,first_name,last_name,email,birthday,age_range'},
function(response) {
...});
每当我尝试获取age_range时,它只是说[object Object]。但我可以得到这个名字和生日。我应该怎么解决这个问题。 我的整个代码: -
function checkLoginState() {
FB.login(function (response) {
if (response.status == 'connected') {
FB.api('/me', {fields: 'name,first_name,last_name,email,birthday,age_range'},
function(response){
document.getElementById('status').innerHTML =response.first_name+
' '+ response.last_name+ ' ' + response.email+ ' ' +response.birthday+ ' ' +
response.age_range;
});
}, { scope: "public_profile,email" });
}
提前谢谢!
答案 0 :(得分:2)
age_range是一个对象,结果如下所示:
"age_range": {
"min": 21
},
例如,尝试使用console.log(response.age_range.min)
。
不确定你对其他事情的意思,你甚至不想要家乡或其他东西。