【问题标题】:Posting status update to Twitter returns 403 forbidden error向 Twitter 发布状态更新返回 403 禁止错误
【发布时间】:2016-12-15 14:02:09
【问题描述】:

我正在使用以下代码尝试将简单的状态更新发布到 Twitter。每次,我都会收到 403 禁止错误。我已经尝试过使用多个帐户和几个不同的状态消息。我错过了什么?

ACAccount *account = [_accountsArray objectAtIndex:1];
ACAccountStore *account_store = [[ACAccountStore alloc] init];
ACAccountType *account_type_twitter = [account_store accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
account.accountType = account_type_twitter;

NSURL *requestURL = [NSURL URLWithString:@"https://api.twitter.com/1.1/statuses/update.json"];

SLRequest *request = [SLRequest requestForServiceType:SLServiceTypeTwitter requestMethod:SLRequestMethodPOST URL:requestURL parameters:dataDict];

request.account = account;

[request performRequestWithHandler:^(NSData *data, NSHTTPURLResponse *response, NSError *error) {

    NSLog(@"%@", response);

}];

【问题讨论】:

  • 嗯,终于用另一部手机试了一下,那次发帖很好。不知道为什么它会在那里工作,而不是第一部手机 - 我授权该应用使用 Twitter,这是我第一次尝试发布内容,所以 API 不会限制我的速度。

标签: ios twitter


【解决方案1】:

原来我在“设置”应用中退出了我的 Twitter 帐户,我猜是因为我换了一部新手机。但是,当我查询 ACAccountStore 时,我的所有帐户仍然显示,所以我没有理由认为它们没有经过身份验证。我会留下这个,以防其他人犯同样的愚蠢错误。

【讨论】:

  • 投了赞成票,因为我确实犯了同样的愚蠢错误!
【解决方案2】:

我遇到了同样的错误,并通过将消息字符长度减少到 140 来修复它。 试试这个https://stackoverflow.com/a/35800216/5425082

【讨论】:

    【解决方案3】:

    我刚刚在尝试将图片发布到测试帐户时遇到了这个错误。通过将图像从大约 4MB 缩小到 1MB 来解决它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-04-05
      • 1970-01-01
      • 1970-01-01
      • 2016-05-16
      • 2022-01-22
      • 2019-11-27
      • 2018-11-03
      相关资源
      最近更新 更多