我正在尝试集成 Ios 6 和 twitter 以使用 slcomposeviewcontroller 发送推文,但我不知道如何从 twitter 帐户获取用户信息。
谁能帮帮我?
最佳答案
您走在正确的轨道上,但是您使用了错误的框架。社交框架中的 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);
}
}
}];
}
关于ios - 如何从 iOS 6 中的推特获取用户信息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14216116/