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的应用程序(不登录设置)。所以,你会告诉我如何检查请求是否签署? –