[英]How can I grab a users profile image using the twitter api (js)?
Is there an easy way to grab a users twitter image with a simple line such as: 有没有一种简单的方法可以用一条简单的线来捕获用户的Twitter图像,例如:
http://www.twitter.com/USERID/picture
If there isn't, what could I possibly look into that has an easy method to grab the user profile image? 如果没有,我可能会考虑采用哪种简单的方法来获取用户个人资料图像?
UPDATE February 2014: The original answer no longer works now v1 of Twitters API has been retired. 2014年2月更新: 原来的答案现在不再有效,Twitters API v1已被淘汰。 The below is the nearest substitute for what was asked, but for v1.1 of the API.
以下是所要求的内容的最接近替代品,但是API的v1.1。
Version 1 of the Twitter API allowed you to do this easily, using a URL such as http://api.twitter.com/1/users/profile_image/:screen_name.format
however that was retired in May 2013. Twitter API的第1版使您可以使用
http://api.twitter.com/1/users/profile_image/:screen_name.format
这样的URL轻松完成此操作,但该URL已于2013年5月停用。
As of Verson 1.1, you cannot get a users profile picture URL without making an authenticated call . 从Verson 1.1开始, 如果不进行经过身份验证的呼叫 , 就无法获取用户的个人资料图片URL 。 Once you have got an authenticated user, simply make a request to any endpoint which returns a users information ( such as
/user/show
), and use the "profile_image_url"; 一旦你得到了一个身份验证的用户,只需做出它返回一个用户的信息(任何端点的请求,如
/user/show
),并使用“profile_image_url”;
jQuery.ajax('/users/show', {
data: {
screen_name: 'mattlunn'
},
headers: {
// All your OAUTH headers
}
}).done(function (res) {
var url = res.profile_image_url;
var img = document.createElement("img");
alert("URL is '" + url + "'");
img.src = url;
document.body.appendChild(img);
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.