我正在使用 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/