TWRequest发帖回复NSURLErrorDomain

时间:2012-05-17 06:20:45

标签: iphone twitter twrequest nsurlerrordomain

我无法使用TWRequest api向推文发送回复。我能够成功发布新的推文/状态,但回复失败,错误如下。请指教

我在回复帖子上收到的错误是:

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 个答案:

答案 0 :(得分:1)

停止寻找TWRequest的任何帮助Twitter.framework已被iOS 6.0弃用 参考资料确实访问了dev.twitter.com

  1. 使用Social.Framework如果您只需要通过推文发布推文或图片,就可以使用SLComposeViewController进行此目的。

  2. 在其他情况下,例如回复推文或收藏或甚至嵌入尝试此单例类: https://github.com/fhsjaagshs/FHSTwitterEngine 阅读它的描述确实启动演示和您的所有设置