2
我總是得到這個twitter API請求401 Unauthorized
響應。這是令人困惑的,因爲我有一個推特會議並正在簽署請求。提前致謝。401未經授權的錯誤使用Twitter API
NSURL *retweetAPIURL = [NSURL URLWithString:[NSString stringWithFormat:@"https://api.twitter.com/1.1/statuses/retweet/%@.json", tweetID]];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:retweetAPIURL];
request.HTTPMethod = @"POST";
if (self.twitterSession) {
[self.twitterSession signRequest:request];
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
operation.responseSerializer = [AFJSONResponseSerializer serializer];
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
block(nil, responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
block(error, nil);
}];
[[NSOperationQueue mainQueue] addOperation:operation];
} else {
block([self createErrorWithMessage:NSLocalizedString(NSLocalizedString(@"TWITTER LOGIN ERROR", nil), nil)], nil);
}
我會嘗試下一個解決方案但問題是我使用Parse.com後端和登錄Twitter的應用程序(不登錄設置)。所以,你會告訴我如何檢查請求是否簽署? –