我可以以某种方式获得比picture.data.url中的一个API返回更大的图像吗?Facebook可邀朋友
针对应用内的朋友我有用户标识符,我可以使用像以下但Inviteable朋友令牌返回,而不是用户名:
http://graph.facebook.com/{0}/picture?width={1}&height={2}
我可以以某种方式获得比picture.data.url中的一个API返回更大的图像吗?Facebook可邀朋友
针对应用内的朋友我有用户标识符,我可以使用像以下但Inviteable朋友令牌返回,而不是用户名:
http://graph.facebook.com/{0}/picture?width={1}&height={2}
当您调用Invitable friends API时,可以使用类型或自己的宽度和高度来缩放附带的图片。
对于预先定义的类型:
/me/invitable_friends?fields=picture.type(large)
为了你自己的宽度和高度:
/me/invitable_friends?fields=picture.width(150).height(150)
您可以修改invitable_friends的picture.data.url访问质量更高图像(可能是原始图像或至少与最初上传的图像相同的尺寸)。
例子:
域和文件名之间删除一切,即: https://fbcdn-profile-a.akamaihd.net/482877_10151573704436719_2137579306_n.jpg
一个很简单的JavaScript函数将解析的网址:
function GetFullImage(url){
var filename = url.replace(/^.*[\\\/]/, '');
return url.substring(0, url.indexOf("/",8)+1) + filename;
}
GetOriginalImage(friend.picture.data.url);
而且,您可以修改50x50部件以提供更大尺寸的尺寸,但这不是gu ranteed解决方案,因为:
1)较大尺寸可能无法使用(用户可能已经上传的小图像)
2)裁剪信息(在上述的例子c62.62.780.780)可以只显示图像正确在50x50。 我敢肯定,可能有足够简单的解决方案来获得您想要的尺寸,但恐怕我还没有把所需的时间放到这里。无论如何希望以上帮助。
您可以修改invitable_friends的picture.data.url以使用您自己的尺寸访问更高质量的图像。在这种Objective-C的例子中,我们使用高度= 120,重量= 120
#define IMAGE_PATTERN @"s120x120"
NSString *url_ = @"https://fbcdn-profile-a.akamaihd.net/hprofile-ak-xpa1/v/t1.0-1/p50x50/1477386_637922472919990_2075386170_n.jpg?oh=afaeeb2448654c3ae05fb87d1a23b504&oe=54F2E920&__gda__=1424976270_d2b5b60376149424116b38783b0ddde0";
NSURL *url = [NSURL URLWithString:url_];
NSString *newUrl = [NSString stringWithFormat:@"%@://%@/%@/%@",
url.scheme,
url.host,
IMAGE_PATTERN,
url.pathComponents.lastObject];
NSLog(@"newUrl: %@", newUrl);
也许这个例子可以帮助:
FB.api('/me/invitable_friends?fields=picture.type(large)', function (response) {
// picture url will be in the response
}
的图像类型是在这个网址
https://developers.facebook.com/docs/graph-api/reference/v2.2/user/picture