gpt4 book ai didi

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

转载 作者:可可西里 更新时间:2023-11-01 05:04:42 27 4
gpt4 key购买 nike

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

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com