ios - 如何从 iOS 6 中的推特获取用户信息?

标签 ios twitter ios6 social-framework slcomposeviewcontroller

我正在尝试集成 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/

相关文章:

php - iPhone SDK 付款后,我的 php IPN 回调中缺少 POST 参数

ios - 如何获取 QLPreviewItem 的文档图标?

ios - 公共(public) iCloud 数据

twitter - 使用 GET 搜索/推文从 Twitter API 获取推文 URL

f# - 使用 Windows Azure 和 F# 进行 Twitter Streaming API 记录和处理

ios - 如果我有一个 UITableViewController 类,我应该在哪里初始化它的实例变量?

objective-c - 没有 UITableViewController 的 UIRefreshControl

ios - Swift SubView 在 tableView 前面

ios6 - 苹果应用程序崩溃然后启动

ruby - 在单引号字符串Ruby中打印打印变量