我有问题通过解析框架发布到twitter。我已经登录使用此我的用户,使用解析框架发布推文
[PFTwitterUtils linkUser:[PFUser currentUser]];
然后我尝试发布使用这个叽叽喳喳,
NSString *bodyString = @"this is a test";
// Explicitly percent-escape the '!' character.
bodyString = [bodyString stringByReplacingOccurrencesOfString:@"!" withString:@"%21"];
NSURL *url = [NSURL URLWithString:@"https://api.twitter.com/1.1/statuses/update.json"];
NSMutableURLRequest *tweetRequest = [NSMutableURLRequest requestWithURL:url];
tweetRequest.HTTPMethod = @"POST";
tweetRequest.HTTPBody = [bodyString dataUsingEncoding:NSUTF8StringEncoding];
[[PFTwitterUtils twitter] signRequest:tweetRequest];
NSURLResponse *response = nil;
NSError *error = nil;
// Post status synchronously.
NSData *data = [NSURLConnection sendSynchronousRequest:tweetRequest
returningResponse:&response
error:&error];
// Handle response.
if (!error) {
NSLog(@"Response: %@", [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]);
} else {
NSLog(@"Error: %@", error);
}
然后抛出这个错误,
Error Domain=NSURLErrorDomain Code=-1012 "The operation couldn’t be completed.
(NSURLErrorDomain error -1012.)" UserInfo=0xac5eac0
{NSErrorFailingURLKey=https://api.twitter.com/1.1/statuses/update.json,
NSErrorFailingURLStringKey=https://api.twitter.com/1.1/statuses/update.json,
NSUnderlyingError=0xc0945b0 "The operation couldn’t be completed.
(kCFErrorDomainCFNetwork error -1012.)"}
任何帮助将是大量赞赏!
https://developer.apple.com/library/mac/documentation/Networking/Reference/CFNetworkErrors/Reference/reference.html了解错误代码的解释。这意味着“取消认证”,所以签名请求时可能出现一些问题? – jrturton