[英]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.