ios - 如何在 iOS 中使用 Twitter Kit/Fabric 从登录用户获取用户个人资料图像

标签 ios objective-c twitter

我正在使用 Fabric 以便在我的应用程序中添加“使用 Twitter 登录”按钮。登录过程工作正常,但我不知道如何(如果可能的话)如何获取登录用户的个人资料图像。

TWTRSession 中是否有包含此信息的任何属性(如 userName 和 userID)?寻找它但我没有找到任何东西?

[TWTRLogInButton buttonWithLogInCompletion:^(TWTRSession *session, NSError *error) {
  // I get user data here...
  // and need to get user Twitter's profile image
}];

谢谢

编辑

感谢 sak 的回答,我想出了办法。

[TWTRLogInButton buttonWithLogInCompletion:^(TWTRSession *session, NSError *error) {
  [[[Twitter sharedInstance] APIClient] loadUserWithID:session.userID completion:^(TWTRUser *user, NSError *error) {
       NSLog(@"User image %@", user.profileImageURL);
  }];
}];

最佳答案

对于遇到此错误的人:

Value of type 'Twitter' has no member 'APIClient'

这对我有帮助,

let twitterClient = TWTRAPIClient(userID: userID)
twitterClient.loadUserWithID(userID) { (user:TWTRUser?, error:NSError?) in
    print(user?.profileImageURL)
}

关于ios - 如何在 iOS 中使用 Twitter Kit/Fabric 从登录用户获取用户个人资料图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28633593/

相关文章:

iphone - 我可以为 NSNotifications 注册一个类吗?我可以将类方法与 NSNotifications 一起使用吗?

r - 使用 R 发送推文

python - 无法导入 Python-Twitter

ios - UITabBar 内的单个 UIViewController 自动旋转

ios - Foursquare field 搜索 API 返回超出半径的结果

ios - 使用 iOS 社交/帐户框架检索 Twitter 用户数据

IOS:识别通用对象

ios - Xcode 6 中的 UITabbar

ios - 当 searchBar 在部分标题中时,UICollectionView reloadData 退出第一响应者/关闭键盘

ios - 从 Firebase 解析数据时无法成功重新加载 UITableView 元素