2012-05-17 74 views
4

我無法使用TWRequest API發送回覆鳴叫。我可以成功發佈新的推文/狀態,但回覆失敗,錯誤如下。請指教TWRequest post reply NSURLErrorDomain

我收到回覆後的錯誤是:

Error Domain=NSURLErrorDomain Code=-1012 "The operation couldn’t be completed. 

(NSURLErrorDomain error -1012.)" UserInfo=0x6c67900 {NSErrorFailingURLKey=https://api.twitter.com/1/statuses/update.json, NSErrorFailingURLStringKey=https://api.twitter.com/1/statuses/update.json, 

NSUnderlyingError=0x6ce28a0 "The operation couldn’t be completed. (kCFErrorDomainCFNetwork error -1012.)"} 

示例代碼如下:

NSDictionary *paramDict = nil; 
if(isReply) 
{ 
    paramDict = [NSDictionary dictionaryWithObjectsAndKeys: 
    in_reply_to_status_id, @"in_reply_to_status_id", 
    status, @"status", 
    nil]; 
    NSLog(@"Status is %@ %@",status,in_reply_to_status_id); 
} 
    else 
{ 
paramDict = [NSDictionary dictionaryWithObject:status forKey:@"status"]; 
} 

TWRequest *sendTweet = [[TWRequest alloc] 
initWithURL:[NSURL URLWithString:@"https://api.twitter.com/1/statuses/update.json"] 
parameters:paramDict 
requestMethod:TWRequestMethodPOST]; 
sendTweet.account = self.account; 
[sendTweet performRequestWithHandler:^(NSData *responseData, 
NSHTTPURLResponse *urlResponse, 
NSError *error) { 
if ([urlResponse statusCode] == 200) { 
dispatch_sync(dispatch_get_main_queue(), ^{ 

NSLog(@"Sent tweet: %@", status); 
}); 
} 
else { 
NSLog(@"Problem sending tweet: %@", error); 
} 
}]; 
+1

解決。我的帳戶對象在回覆期間爲零。 – lostfound

回答

1

停止尋找與TWRequest Twitter.framework任何幫助與iOS 6.0棄用任何 參考請訪問dev.twitter.com

  1. 使用Social.Framework,如果您只需發佈推文或圖片,就可以使用SLComposeViewController來實現此目的。

  2. 在這樣回答鳴叫或喜愛,甚至嵌入試試這個單例類其他情況: https://github.com/fhsjaagshs/FHSTwitterEngine 閱讀它的描述不啓動演示,所有的設置