我有問題通過解析框架發佈到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