ios - iOs 8 上的 Twitter API 有什么问题?

标签 ios objective-c twitter

我想在 Objetive-C 中创建一个在 Twitter 帐户中即时“关注”的 Action ,但是当我启动我的应用程序时它崩溃了。谁能告诉我哪里出了问题?

它返回thread 1 exc_bad_access

- (IBAction)Twitter:(id)sender {

    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];

                NSMutableDictionary *tempDict = [[NSMutableDictionary alloc] init];
                [tempDict setValue:@"user" forKey:@"UserName"];
                [tempDict setValue:@"true" forKey:@"follow"];

                NSURL *URLTwitter = [NSURL URLWithString:@"https://api.twitter.com/1.1/friendships/create.format"];

                SLRequest *postRequest = [SLRequest requestForServiceType:@"Twitter" requestMethod:SLRequestMethodPOST URL:URLTwitter parameters:tempDict];

                [postRequest setAccount:twitterAccount];

                [postRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
                    NSString *output = [NSString stringWithFormat:@"HTTP response status: %li", [urlResponse statusCode]];
                    NSLog(@"%@", output);

                }];
            }
        }
    }];
}

最佳答案

您的推特网址不正确。应该是

https://api.twitter.com/1.1/friendships/create.json

关于ios - iOs 8 上的 Twitter API 有什么问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27465090/

相关文章:

ios - LibGDX RoboVM Robopods Facebook 登录错误

c++ - 在 iOS 目标低于 5.0 的 iPhone 应用程序中使用 C++

objective-c - 将 block 存储在数组中

objective-c - 记录 NSNotifications

twitter - 在 ios7 中使用 twitter 登录并获取 twitter 用户配置文件

java - 如何从 'Twitter4J' 中的用户那里获取电子邮件地址?

ios - Sprite-Kit 类别位掩码对于物理体来说是错误的

ios - 基于数组比较更新 UICollectionView

ios - NSExtensionActivationRule & iOS 应用扩展 : how to activate the extension in iTunes

ios - 如何使用 SLRequest 获取 twitter 时间线