我一直试图让Facebook API加载我的照片。我只是继续得到数组[0]。
我是Facebook Developer的新手,所以任何帮助都会很棒。
由于
我的代码:
if(response.status == "connected"){
FB.api("/me/", function(resp2){
console.log(resp2);
$("#userinfo").append("<br/>Welcome "+resp2.name+"!");
// store info in object
userinfo.name = resp2.name;
//userinfo.gender = resp2.name;
//userinfo.id = resp2.id;
//alert(resp2.id)
});
FB.api("/me/picture", function(pic_resp){
console.log(pic_resp);
$("#userinfo").append("<img src='"+pic_resp.data.url+"' />");
// store info in object
userinfo.pic = pic_resp.data.url;
});
FB.api("/me/photos", function(photos_resp){
console.log(photos_resp);
});
} else{
FB.login(function(response){
},{scope: 'user_photos'});
}
答案 0 :(得分:0)
根据FB API Docs,响应中存在“错误”属性。请检查一下。
引用:
/* make the API call */
FB.api(
"/me/photos",
function (response) {
if (response && !response.error) {
/* handle the result */
}
}
);
答案 1 :(得分:0)
如果user_photos
在授权过程中不起作用,您很可能会尝试使用不是App Admin / Developer / Tester的用户。在您允许其他任何用户使用该权限之前,您必须完成审核流程:https://developers.facebook.com/docs/apps/review/login
如果情况并非如此,如果您仍然没有被要求获得许可,那么您的登录过程就会出现问题。