im trying to return the profile picture of a user with the facebook api, but i get an error in chrome about the link. here is the code
FB.getLoginStatus(function(response){
if(response.status=="connected"){
var token=response.authResponse.accessToken;
console.log(token);
FB.api('me/picture?type=square',function(response){
console.log(response);
});
}else{
FB.login(function(response){
console.log(response);
},{scope:"email"});
}
});
});
and the error
Uncaught SyntaxError: Unexpected token ILLEGAL 27开发者_JAVA技巧5226_100002726490078_140247_q.jpg:1
why is this happening? i dont even know where to start looking for a solution, because i dont know where this error is even coming from.
The problem is that a call to https://graph.facebook.com/me/picture?type=square will return image data and the FB.api
expects JSON.
For the 50×50 square version of the profile picture, you can get the url from /me?fields=picture&type=square
:
FB.api('/me?fields=picture&type=square',function(response){
console.log(response.picture);
});
/me?fields=picture&type=square
- 50×50/me?fields=picture&type=small
- 50 pixels wide, variable height/me?fields=picture&type=large
- about 200 pixels wide, variable height
精彩评论