我只想使用JQuery检索Twitter个人资料图片的网址
为此,我使用:
$.ajax({
type: "GET",
url: "https://api.twitter.com/1/users/profile_image/twitterapi.json",
dataType: "jsonp",
success: function(data){
console.log('success');
},
error: function(data){
console.log('error');
}
});
但是我得到这个错误
Uncaught SyntaxError: Unexpected token ILLEGAL
谁知道我的错误在哪里?
最佳答案
Uncaught SyntaxError: Unexpected token ILLEGAL
尝试在浏览器中打开该URL。您将“重定向”到其他URL。通过
curl -v
验证并检查Location: ...
header 。解决方案是从URL请求JSONP:
https://api.twitter.com/1/users/show.json?screen_name=TwitterAPI&include_entities=true&callback=foo
您将从根对象的
profile_image_url
字段获取图像URL。
关于url - 使用JQuery获取Twitter个人资料图片网址,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11566653/