4 twitter ios ios6 slcomposeviewcontroller social-framework
我正在尝试整合Ios 6和twitter以使用slcomposeviewcontroller发送推文,但我无法弄清楚如何从Twitter帐户获取用户信息.
有谁能够帮我?
Mic*_*lum 11
你走在正确的轨道上,但你使用的是错误的框架.社交框架中的SLComposeViewController类仅用于共享.如果要获取有关当前登录帐户的信息,则必须使用帐户框架.
#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);
}
}
}];
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5266 次 |
| 最近记录: |