ios - Twitter 上的 SLRequest 给我这个 : HTTP response status: 403 Error 0error (null)

标签 ios twitter slrequest

我在 Twitter 上使用 SLRequest,直到几天前使用下面的代码一切正常,但现在响应为空并且错误描述为空,这是我一直使用的代码:

ACAccountStore *accountStoreTw = [[ACAccountStore alloc] init];

ACAccountType *accountTypeTw = [accountStoreTw accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
[accountStoreTw requestAccessToAccountsWithType:accountTypeTw options:NULL completion:^(BOOL granted, NSError *error) {
    if(granted) {

        FMDatabase *db = [FMDatabase databaseWithPath:[self databasePath]];

        if ([db open]) {
            FMResultSet *tw_name_q = [db executeQuery:@"SELECT tw_username FROM settings WHERE id = 1"];

            NSString *tw_name = @"";

            while ([tw_name_q next]) {
                tw_name = [tw_name_q stringForColumn:@"tw_username"];
            }

            if (![tw_name isEqualToString:@""]) {

                NSArray *accountsArray = [accountStoreTw accountsWithAccountType:accountTypeTw];

                for (ACAccount *tw_account in accountsArray) {

                    if ([[tw_account username] isEqualToString:tw_name]) {

                        SLRequest* twitterRequest = [SLRequest requestForServiceType:SLServiceTypeTwitter
                                                                       requestMethod:SLRequestMethodPOST
                                                                                 URL:[NSURL URLWithString:@"http://api.twitter.com/1/statuses/update.json"]
                                                                          parameters:[NSDictionary dictionaryWithObject:msg_post forKey:@"status"]];

                        [twitterRequest setAccount:tw_account];

                        [twitterRequest performRequestWithHandler:^(NSData* responseData, NSHTTPURLResponse* urlResponse, NSError* error) {
                            NSLog(@"text response: %@", [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding]);
                            NSLog(@"error: %@",error.localizedDescription);
                            NSString *output = [NSString stringWithFormat:@"HTTP response status: %i Error %d", [urlResponse statusCode],error.code];
                            NSLog(@"%@ error %@", output,error.description);

                        }];

                        break;
                    }
                }
            }
        }

        [db close];
    }

}];

现在这个日志给我这个:

text response: 
error: (null)
403 Error 0 error (null)

问题是什么?有解决办法吗?

最佳答案

有一个recent change to the Twitter API .您现在只能使用 HTTPS 调用它。

您应该确保您/您的图书馆使用的 URL 以

开头
https://api.twitter.com/1.1/

(注意 http 之后的额外 s。)

关于ios - Twitter 上的 SLRequest 给我这个 : HTTP response status: 403 Error 0error (null),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21133750/

相关文章:

ios - render回调函数和input回调函数有什么区别

Ruby Twitter 如何授权用户?

ios - 使用 SLRequest 将多张图片上传到 facebook

ios - 使用SLRequest发布到Facebook,但没有应用ID

ios - 在标签栏中滚动功能很奇怪

ios - 应用内购买 - 订阅 - 不基于 Apple Id

button - Twitter 按钮 'url' 参数不包含有效的 URL

ios - 在 slrequest performrequestwithhandler 使用 twitter 句柄停止后更新 uitableviewcell 中的文本字段

ios - 如何使用 SLRequest 获取大尺寸的 facebook 个人资料图片?

ios - 在 MDM 中更新安装在 iOS 设备中的配置文件