[英]getting facebook thumbnail profile picture
有谁知道我如何使用javascript sdk获取Facebook用户的缩略图/头像?
我知道要获得完整尺寸的图片,我可以进行以下操作:
//Get a list of all the albums
FB.api('/me/albums', function (response) {
for (album in response.data) {
// Find the Profile Picture album
if (response.data[album].name == "Profile Pictures") {
// Get a list of all photos in that album.
FB.api(response.data[album].id + "/photos", function(response) {
//The image link
image = response.data[0].images[0].source;
});
}
}
});
不确定如何获取缩略图/头像大小。 大小约为50x50
您也可以只使用<img>
标记和特殊URL来执行相同的操作:
<img src="http://graph.facebook.com/<UID>/picture?type=square" />
从2012年8月开始,您可以为用户缩略图定义自定义尺寸,例如https://graph.facebook.com/USER_ID/picture?width=WIDTH&height=HEIGHT
。 了解更多信息, https://developers.facebook.com/docs/reference/api/using-pictures/ 。
我做了以下事情来完成同样的事情:
FB.api( { method: 'fql.query', query: 'SELECT name,email,pic_small FROM user WHERE uid=' + uid // uid is the id of the user. }, function(response) { var user = response[0]; // user.pic_small contains the url for the small sized profile pic });
由于您拥有此人的UID,因此可以轻松获取图像。 例如,我的个人资料图片网址应为graph.facebook.com/v2.8/1375341351/picture?type=small(现在更改type参数并享受不同的尺寸。。欢呼...尺寸可以小,普通,相册,大,方形
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.