[英]Uncaught SyntaxError: Unexpected token ILLEGAL when returning link to facebook profile picture
我试图用 facebook api 返回用户的个人资料图片,但我在 chrome 中收到有关链接的错误。 这是代码
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"});
}
});
});
和错误
Uncaught SyntaxError: Unexpected token ILLEGAL 275226_100002726490078_140247_q.jpg:1
为什么会这样? 我什至不知道从哪里开始寻找解决方案,因为我什至不知道这个错误来自哪里。
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.
对于 50×50 方形版本的头像,您可以从/me?fields=picture&type=square
获取 url:
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 像素宽,可变高度/me?fields=picture&type=large
- 大约 200 像素宽,可变高度
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.