使用 Fabric 在 IOS 10.2 中登录 Twitter 时获取个人资料图片和更多信息等详细信息
Get detail like profile Picture and more Informations while Twitter login in IOS 10.2 using Fabric
如何在使用 Fabric 登录 IOS 时获取个人资料图片和更多信息等详细信息。
我写这段代码 --
[[Twitter sharedInstance] logInWithCompletion:^
(TWTRSession *session, NSError *error) {
if (session) {
/* 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(@"error: %@", [error localizedDescription]);
}
}];
但它显示了这种类型的错误:
我终于找到了自己的答案:
[[Twitter sharedInstance] logInWithCompletion:^
(TWTRSession *session, NSError *error) {
if (session) {
NSLog(@"signed in as %@", [session userName]);
/* Get user info */
NSString *userID = [Twitter sharedInstance].sessionStore.session.userID;
TWTRAPIClient *client = [[TWTRAPIClient alloc] initWithUserID:userID];
[client loadUserWithID:userID completion:^(TWTRUser *user, NSError *error) {
NSLog(@"Profile image url = %@", user.profileImageLargeURL);
}];
} else {
NSLog(@"error: %@", [error localizedDescription]);
}
}];
它给你 url 张头像。
如何在使用 Fabric 登录 IOS 时获取个人资料图片和更多信息等详细信息。 我写这段代码 --
[[Twitter sharedInstance] logInWithCompletion:^
(TWTRSession *session, NSError *error) {
if (session) {
/* 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(@"error: %@", [error localizedDescription]);
}
}];
但它显示了这种类型的错误:
我终于找到了自己的答案:
[[Twitter sharedInstance] logInWithCompletion:^
(TWTRSession *session, NSError *error) {
if (session) {
NSLog(@"signed in as %@", [session userName]);
/* Get user info */
NSString *userID = [Twitter sharedInstance].sessionStore.session.userID;
TWTRAPIClient *client = [[TWTRAPIClient alloc] initWithUserID:userID];
[client loadUserWithID:userID completion:^(TWTRUser *user, NSError *error) {
NSLog(@"Profile image url = %@", user.profileImageLargeURL);
}];
} else {
NSLog(@"error: %@", [error localizedDescription]);
}
}];
它给你 url 张头像。