gpt4 book ai didi

ios - Twitter-“关注”按钮

转载 作者:行者123 更新时间:2023-12-01 17:32:44 27 4
gpt4 key购买 nike

我目前正在使用iOS应用程序进行开发,该应用程序会从流式API捕获一些推文。因此,我使用用户名和密码进行身份验证。除此之外,我想给用户提供在Twitter上关注某些人的机会。我创建了一个UIButton,现在想调用url或类似的东西来跟随特定的用户。这可能吗?

最佳答案

如果您使用iOS 6在Twitter上关注用户:

-(void)followMe
{
ACAccountStore *accountStore = [[ACAccountStore alloc] init];
ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];

[accountStore requestAccessToAccountsWithType:accountType options:nil completion:^(BOOL granted, NSError *error) {
if(granted) {
// Get the list of Twitter accounts.
NSArray *accountsArray = [accountStore accountsWithAccountType:accountType];

// For the sake of brevity, we'll assume there is only one Twitter account present.
// You would ideally ask the user which account they want to tweet from, if there is more than one Twitter account present.
if ([accountsArray count] > 0) {
// Grab the initial Twitter account to tweet from.
ACAccount *twitterAccount = [accountsArray objectAtIndex:0];

NSMutableDictionary *tempDict = [[NSMutableDictionary alloc] init];
[tempDict setValue:@"twitter_name" forKey:@"screen_name"];
[tempDict setValue:@"true" forKey:@"follow"];
NSLog(@"*******tempDict %@*******",tempDict);

//requestForServiceType

SLRequest *postRequest = [SLRequest requestForServiceType:SLServiceTypeTwitter requestMethod:SLRequestMethodPOST URL:[NSURL URLWithString:@"https://api.twitter.com/1.1/friendships/create.json"] parameters:tempDict];
[postRequest setAccount:twitterAccount];
[postRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
NSString *output = [NSString stringWithFormat:@"HTTP response status: %i Error %d", [urlResponse statusCode],error.code];
NSLog(@"%@error %@", output,error.description);
}];
}

}
}];
}

关于ios - Twitter-“关注”按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14797341/

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