サーバーの Twitter アクセス トークンを取得するためにリバース oauth を実行しようとしています。
リクエストを送信してレスポンスを受け取る方法を理解しましたが、そうすると次のエラーが表示されます。
Error: The operation couldn’t be completed. (NSURLErrorDomain error -1012.)
これを調べたところ、ユーザーがリクエストをキャンセルしたことを意味すると書かれています。これがどのように可能かはわかりません。また、修正方法もわかりません。
これが私のコードです:
NSTimeInterval timeStamp = [[NSDate date] timeIntervalSince1970];
NSNumber *timeStampObj = [NSNumber numberWithDouble: timeStamp];
NSString *oauth_nonce = [self genRandStringLength:32];
NSString *oauth_timestamp = [timeStampObj stringValue];
NSURL *feedURL = [NSURL URLWithString:@"https://api.twitter.com/oauth/request_token"];
NSDictionary *parameters = [NSDictionary dictionaryWithObjectsAndKeys: @"my key here", @"oauth_consumer_key", oauth_nonce, @"oauth_nonce", @"HMAC-SHA1", @"oauth_signature_method", oauth_timestamp, @"oauth_timestamp", @"1.0", @"oauth_version", @"reverse_auth", @"x_auth_mode", nil];
SLRequest *twitterFeed = [SLRequest requestForServiceType:SLServiceTypeTwitter requestMethod:SLRequestMethodPOST URL:feedURL parameters:parameters];
twitterFeed.account = self.userAccount;
// Making the request
[twitterFeed performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
dispatch_async(dispatch_get_main_queue(), ^{
// Check if we reached the reate limit
if ([urlResponse statusCode] == 429) {
NSLog(@"Rate limit reached");
return;
}
// Check if there was an error
if (error) {
NSLog(@"The Error is: %@", error.localizedDescription);
return;
}
// Check if there is some response data
if (responseData) {
NSLog(@"%@", responseData);
}
});
}];
私が見逃している単純なものがあるに違いありません。これがプロジェクトの完成を妨げています。どんな助けでも素晴らしいでしょう、ありがとう!