gpt4 book ai didi

ios - 如何使用 Twitter 工具包/Fabric iOS 获取登录用户的个人资料 URL

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:14:59 25 4
gpt4 key购买 nike

我正在使用 iOS Twitter Kit 在我的 iOS 应用程序中使用 Twitter 实现登录机制。我已经使用 Fabric 成功安装了 Twitter 工具包。我正在使用以下代码登录并获取登录用户的详细信息。

TWTRLogInButton *logInButton = [TWTRLogInButton buttonWithLogInCompletion:^(TWTRSession *session, NSError *error) {
// play with Twitter session
if (session) {
NSLog(@"Twitter signed in as -> name = %@ id = %@ ", [session userName],[session userID]);

/* Get user info */
[[[Twitter sharedInstance] APIClient] loadUserWithID:[session userID]
completion:^(TWTRUser *user,
NSError *error)
{
// handle the response or error
if (![error isEqual:nil]) {
NSLog(@"Twitter info -> user = %@ ",user);
} else {
NSLog(@"Twitter error getting profile : %@", [error localizedDescription]);
}
}];

} else {
NSLog(@"Twitter error signed in : %@", [error localizedDescription]);
}
}];
logInButton.center = self.view.center;
[self.view addSubview:logInButton];

使用接收到的 TWTRUser *user 对象,我能够访问用户信息,例如姓名、屏幕名称、个人资料图像 url。有没有办法获取其他用户信息,例如用户的个人资料页面 url、电话号码等?

最佳答案

TWTRLogInButton *logInButton = [TWTRLogInButton buttonWithLogInCompletion:^(TWTRSession *session, NSError *error) {
// play with Twitter session
if (session) {
NSLog(@"Twitter signed in as -> name = %@ id = %@ ", [session userName],[session userID]);

/* Get user info */
[[[Twitter sharedInstance] APIClient] loadUserWithID:[session userID]
completion:^(TWTRUser *user,
NSError *error)
{
// handle the response or error
if (![error isEqual:nil]) {
NSLog(@"Twitter info -> user = %@ ",user);
NSString *urlString = [[NSString alloc]initWithString:user.profileImageLargeURL];
NSURL *url = [[NSURL alloc]initWithString:urlString];
NSData *pullTwitterPP = [[NSData alloc]initWithContentsOfURL:url];

UIImage *profImage = [UIImage imageWithData:pullTwitterPP];


} else {
NSLog(@"Twitter error getting profile : %@", [error localizedDescription]);
}
}];

} else {
NSLog(@"Twitter error signed in : %@", [error localizedDescription]);
}
}];
logInButton.center = self.view.center;
[self.view addSubview:logInButton];

关于ios - 如何使用 Twitter 工具包/Fabric iOS 获取登录用户的个人资料 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29120055/

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