【发布时间】:2014-04-03 11:16:37
【问题描述】:
对于这个 twitter API 请求,我总是收到 401 Unauthorized 响应。这很令人困惑,因为我有一个 Twitter 会话并且正在签署请求。提前致谢。
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);
}
【问题讨论】:
标签: ios objective-c twitter parse-platform