繁体   English   中英

如何获得(朋友的)个人资料照片

[英]How can I get profile picture (of friend)

我想获取用户的朋友个人资料图片,但我希望图片的字体较大。

假设我对taggable_friends问题(本身是一个单独的问题),所以我得到这样的信息:

登录名和权限:

    FBLoginView *loginView = [[FBLoginView alloc] initWithReadPermissions: @[@"public_profile", @"email", @"user_friends"]];

    loginView.frame = CGRectOffset(loginView.frame, (self.view.center.x - (loginView.frame.size.width / 2)), (self.view.center.y - (loginView.frame.size.height / 2)));
    [self.view addSubview:loginView];

现在是taggable_friends

FBRequest* friendsRequest = [FBRequest requestWithGraphPath:@"me?fields=invitable_friends" parameters:nil HTTPMethod:@"GET"];
[friendsRequest startWithCompletionHandler: ^(FBRequestConnection *connection,
                                              NSDictionary* result,
                                              NSError *error) {
    NSArray* friends = [[result objectForKey:@"invitable_friends"] objectForKey:@"data"];
    NSLog(@"Found: %i friends", friends.count);
    for (NSDictionary<FBGraphUser>* friend in friends) {
        NSLog(@"friend.name %@", friend.name);
        NSLog(@"friend.objectID %@", friend.objectID);

    }

}];

好的,所以有了objectID ,如何使用它来获取用户的大型个人资料图片?

这对我不起作用:

https://graph.facebook.com/USER_ID/picture?type=large

由于用户ID约为50个字符,通常不是10-12个字符。

有什么帮助吗?

提前致谢!

您使用的ID不是朋友的真实ID。 由于您从未访问过他们的个人资料,因为他们从未使用过您的应用,因此该人将充当占位符。 但是,您可以编辑以下示例url中以粗体突出显示的picture-> data-> url中找到的url,以编辑其个人资料图像的大小。

https://fbcdn-profile-a.akamaihd.net/hprofile-ak-prn2/t1.0-1/ c0.0.100.100 / p100x100 /1470158_10201991701127909_302023572_n.jpg

c0.0.100.100表示​​图像容器的大小

p100x100代表图像本身的大小

这两个值应匹配以获得最佳效果。 我确实注意到,对于容器和图像,您都不能超过200X200px。 Facebook可能会限制大小设置。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM