使用JQuery获取Twitter个人资料图片url
我只想使用JQuery检索Twitter个人资料图片的url 为此,我使用:使用JQuery获取Twitter个人资料图片url,url,jquery,twitter,syntax-error,image,Url,Jquery,Twitter,Syntax Error,Image,我只想使用JQuery检索Twitter个人资料图片的url 为此,我使用: $.ajax({ type: "GET", url: "https://api.twitter.com/1/users/profile_image/twitterapi.json", dataType: "jsonp", success: function(data){ console.log('success'); }, error: function(
$.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
谁知道我的错在哪里
未捕获的语法错误:意外标记非法
尝试在浏览器中打开该URL。您将被“重定向”到其他URL。通过curl-v
验证,并检查位置:…
标题
解决方案是从url请求JSONP:
您将从根对象的
profile\u image\u URL
字段获取图像URL。这是一个静态URL,可以获取最新的twitter配置文件图像URL
https://twitter.com/{{#twitterUserName}}/profile_image?size=normal
我的twitter用户名是rkramakrishna17
https://twitter.com/rkramakrishna17/profile_image?size=normal
编辑1:
根据@juanmirocks的建议,我们可以通过添加?size=origianl来获得原始图像
https://twitter.com/{{#twitterUserName}}/profile_image?size=original
是的,但实际上我也想获得原始大小的图片,/show.json不提供原始大小如何检查JQuery$.ajax中的位置头?这就是获得完整大小图像@kschaeffler:
var obj=$.ajax({..});var headers=obj.getAllResponseHeaders()代码>正是我需要的。您还可以将大小设置为original