【问题标题】:How to get user info from twitter in ios 6?如何在 iOS 6 中从 Twitter 获取用户信息?
【发布时间】:2012-12-22 08:56:39
【问题描述】:
我正在尝试集成 Ios 6 和 twitter 以使用 slcomposeviewcontroller 发送推文,但我不知道如何从 twitter 帐户获取用户信息。
谁能帮帮我?
【问题讨论】:
标签:
ios
twitter
ios6
social-framework
slcomposeviewcontroller
【解决方案1】:
您在正确的轨道上,但您使用了错误的框架。社交框架中的 SLComposeViewController 类仅用于共享。如果您想获取有关当前登录帐户的信息,则必须使用Accounts Framework。
#import <Accounts/Accounts.h>
- (void)getTwitterAccountInformation
{
ACAccountStore *accountStore = [[ACAccountStore alloc] init];
ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
[accountStore requestAccessToAccountsWithType:accountType options:nil completion:^(BOOL granted, NSError *error) {
if(granted) {
NSArray *accountsArray = [accountStore accountsWithAccountType:accountType];
if ([accountsArray count] > 0) {
ACAccount *twitterAccount = [accountsArray objectAtIndex:0];
NSLog(@"%@",twitterAccount.username);
NSLog(@"%@",twitterAccount.accountType);
}
}
}];
}