javascript 获取 facebook 缩略图个人资料图片
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5771929/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
getting facebook thumbnail profile picture
提问by adit
Does anyone know how I can get a thumbnail/avatar of a facebook user using the javascript sdk?
有谁知道如何使用 javascript sdk 获取 facebook 用户的缩略图/头像?
I know to get the full size picture I can do the folllowing:
我知道要获得全尺寸图片,我可以执行以下操作:
//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;
});
}
}
});
Not sure on how to get the thumbnail/avatar size. Something like a 50x50 size
不确定如何获取缩略图/头像大小。像 50x50 大小的东西
回答by Jimmy Sawczuk
You can also just use an <img>
tag with a special URL to do the same thing:
你也可以使用<img>
带有特殊 URL的标签来做同样的事情:
<img src="http://graph.facebook.com/<UID>/picture?type=square" />
回答by Gajus
As of August 2012, you can define custom dimensions for the user thumbnail, e.g. https://graph.facebook.com/USER_ID/picture?width=WIDTH&height=HEIGHT
. Find out more, https://developers.facebook.com/docs/reference/api/using-pictures/.
自 2012 年 8 月起,您可以为用户缩略图定义自定义尺寸,例如https://graph.facebook.com/USER_ID/picture?width=WIDTH&height=HEIGHT
。了解更多信息,https://developers.facebook.com/docs/reference/api/using-pictures/。
回答by Arihant Nahata
I did the following to accomplish the same thing:
我做了以下事情来完成同样的事情:
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 });
回答by Manish Mudgal
Since you have the UID of the person, you can easily get the image. For example, my profile image URL should be graph.facebook.com/v2.8/1375341351/picture?type=small (now change the type parameter and enjoy different sizes.. cheers... sizes can be small, normal, album, large, square
由于您拥有此人的 UID,因此您可以轻松获取图像。例如,我的个人资料图片 URL 应该是 graph.facebook.com/v2.8/1375341351/picture?type=small(现在更改类型参数并享受不同的尺寸..干杯...尺寸可以是小、普通、相册, 大, 方形