【问题标题】:How to get user info from twitter in ios 6?如何在 iOS 6 中从 Twitter 获取用户信息?
【发布时间】:2012-12-22 08:56:39
【问题描述】:

我正在尝试集成 Ios 6 和 twitter 以使用 slcomposeviewcontroller 发送推文,但我不知道如何从 twitter 帐户获取用户信息。

谁能帮帮我?

【问题讨论】:

  • 你能更好地解释一下你做了什么以及你想要什么吗? whathaveyoutried.com
  • 我要显示用户名和关注人数

标签: 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);
            }
        }
    }];
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-11-12
    • 1970-01-01
    • 2015-11-22
    • 1970-01-01
    • 2013-07-31
    • 2011-09-17
    • 2012-03-16
    相关资源
    最近更新 更多