0

リツイート機能を実装していますが、POST 後に不正な 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;
    }

  });
}];

何か案は?何か不足していますか?ありがとう!

4

3 に答える 3

1

私の悪い。リクエスト「...%@.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];
于 2013-10-07T18:37:24.503 に答える
0

リクエストにアカウントを添付する必要があります。

// create a request
NSURL *url = [NSURL URLWithString:@"https://api.twitter.com/1.1/statuses/user_timeline.json"];

SLRequest *request = [SLRequest requestForServiceType:SLServiceTypeTwitter
                                        requestMethod:SLRequestMethodGET
                                                  URL:url
                                           parameters:@{@"screen_name":@"nst021"}];

// attach an account to the request
NSArray *twitterAccounts = [accountStore accountsWithAccountType:twitterAccountType];
[request setAccount:[twitterAccounts lastObject]];

// execute the request
[request performRequestWithHandler:^(NSData *responseData,
                                     NSHTTPURLResponse *urlResponse,
                                     NSError *error) {
    // caution, you're on an arbitrary queue here...
}
于 2013-10-09T11:12:00.013 に答える
0

これの代わりに


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


これを試して


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


同じメッセージを何度も再投稿することはできません。スパムと見なされ、このリンクも表示される可能性があります。

于 2013-10-07T07:42:09.363 に答える