带有 SLRequest 的 iOS 转发返回错误的 URL 错误

标签 ios twitter slrequest

我正在实现转发功能,但在发布后我不断收到错误的 URL 错误。 这是我的代码:

SLRequest *twitterRequest = [SLRequest requestForServiceType:SLServiceTypeTwitter requestMethod:SLRequestMethodPOST URL:[NSURL URLWithString:@"https://api.twitter.com/1.1/statuses/retweet/%@.json"] parameters:[NSDictionary dictionaryWithObject:tweetId forKey:@"id"]];

[twitterRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
  dispatch_async(dispatch_get_main_queue(), ^{

    if ([urlResponse statusCode] == 429) {
        NSLog(@"Rate limit reached");
        return;
    }

    if (error) {
        NSLog(@"Error: %@", error.localizedDescription);
        return;
    }

  });
}];

有什么想法吗?我错过了什么吗?谢谢!

最佳答案

我的错。我在创建请求“...%@.json”时忘记传递字符串。

SLRequest *twitterRequest = [SLRequest requestForServiceType:SLServiceTypeTwitter requestMethod:SLRequestMethodPOST URL:[NSURL URLWithString:[NSString stringWithFormat:@"https://api.twitter.com/1.1/statuses/retweet/%@.json",@"490794578250059776"]] parameters:nil];

关于带有 SLRequest 的 iOS 转发返回错误的 URL 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19219260/

相关文章:

ios - 如何使用 faSTLane 和 circleci 将 ipa 文件上传到 Dropbox?

ios - 无法分配给属性 'frame' 是一个 'let' 常量

ios - NSObject 在 ViewDidLoad 和 cellForRowAtIndexPath 之间更改属性值

python - 快速发出多个 twitter API post 请求

ios - 尝试通过 ACAccount 和 SLRequest 访问 Facebook 时的 invalid_token

ios - 无法保存与扩展程序共享的网址

c# - Twitter 中的简单例份验证和 OAuth 身份验证有什么区别?

python - 无法在 python 中删除某些嵌套的 JSON 对象

ios - 无法在 ios 中获取用户个人资料照片