我使用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);
}];
}];
发布于 2015-02-21 00:43:46
我不认为TWTRSession对象具有用户的图像,但是您可以使用会话来请求TWTRUser对象,这将具有您需要的内容。
发布于 2016-05-16 21:47:47
对于那些收到此错误的人:
Value of type 'Twitter' has no member 'APIClient'
这对我有帮助
let twitterClient = TWTRAPIClient(userID: userID)
twitterClient.loadUserWithID(userID) { (user:TWTRUser?, error:NSError?) in
print(user?.profileImageURL)
}
发布于 2017-08-03 17:48:47
尝试以下代码以获取配置文件图像-
Swift 3
let twitterClient = TWTRAPIClient(userID: session?.userID)
twitterClient.loadUser(withID: (session?.userID)!, completion: { (user, error) in
print(user!.profileImageURL)
})
https://stackoverflow.com/questions/28633593
复制相似问题