gpt4 book ai didi

ios - Facebook iOS SDK 和 swift : how get user's profile picture

转载 作者:IT王子 更新时间:2023-10-29 05:08:39 24 4
gpt4 key购买 nike

我已经在 Xcode 6 中集成了 Facebook sdk(使用 swift)。在登录期间,我请求 public_profile 权限:

FBSession.openActiveSessionWithReadPermissions(["public_profile"], allowLoginUI: true, completionHandler: {
...
...

所以我请求用户的信息:

FBRequestConnection.startForMeWithCompletionHandler { (connection, user, error) -> Void in
...
...

为什么用户对象不包含头像?如何获取用户个人资料图片?它不是 public_profile 的一部分?

我得到以下信息:

2015-01-25 01:25:18.858 Test[767:23804] {
"first_name" = xxx;
gender = xxx;
id = xxxxxxxxx;
"last_name" = xxxxxx;
link = "https://www.facebook.com/app_scoped_user_id/xxxxxxxxx/";
locale = "xxxxx";
name = "xxxxxxx xxxxxxx";
timezone = 1;
"updated_time" = "2013-12-21T18:45:29+0000";
verified = 1;
}

P.S: xxx为了隐私

最佳答案

个人资料图片实际上是公开的,您只需将用户 ID 添加到 Facebook 指定的个人资料图片 url 地址即可,例如:

var userID = user["id"] as NSString     
var facebookProfileUrl = "http://graph.facebook.com/\(userID)/picture?type=large"

这个特定的 url 地址应该返回用户个人资料图片的“大”版本,但还有更多的照片选项可用 in the docs .

关于ios - Facebook iOS SDK 和 swift : how get user's profile picture,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28131970/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com