从iPhone应用程序向Wordpress博客发表评论

从iPhone应用程序向Wordpress博客发表评论,iphone,ios,wordpress,Iphone,Ios,Wordpress,我使用代码在wordpress博客上发表了以下问题的评论: 为了从UITextFields获取文本,我做了一些修改: - (IBAction)postComment:(id)sender { NSString *post_url = @"http://movilarena.com/wp-comments-post.php"; NSString *post_content = @"comment_post_ID=%@&comment_parent=%@&autho

我使用代码在wordpress博客上发表了以下问题的评论:

为了从UITextFields获取文本,我做了一些修改:

- (IBAction)postComment:(id)sender {
    NSString *post_url = @"http://movilarena.com/wp-comments-post.php";
    NSString *post_content = @"comment_post_ID=%@&comment_parent=%@&author=%@&email=%@&comment=%@";

    NSString *post_str = [NSString stringWithFormat:post_content, @"1", @"0", self.txtName.text, self.txtEmail.text, self.txtComment.text];
    NSData *data = [NSData dataWithBytes:[post_str UTF8String] length:[post_str length]];

    NSURL * url = [NSURL URLWithString:post_url];
    NSMutableURLRequest *req = [[NSMutableURLRequest alloc] initWithURL:url];
    [req setHTTPMethod:@"POST"];
    [req setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"content-type"];
    [req setHTTPBody:data];

    //Synchronous
    NSURLResponse *response;
    NSError *err;
    NSData *ret = [NSURLConnection sendSynchronousRequest:req returningResponse:&response error:&err];

    NSString *retString = [NSString stringWithUTF8String:[ret bytes]];
    NSLog(@"%@",retString);
}
我的问题是sendSynchronousRequest返回错误:

执行被中断,原因:EXC_错误访问(代码=1, 地址=0x0)。进程已返回到之前的状态 执行


如果有任何建议能找出问题所在,我将不胜感激。我使用XCode 4.5.2,并在配备iOS 6.0.1的iPhone 4S上运行代码。字段
comment\u post\u ID
应该是我试图回复的帖子的ID

NSString *post_content = @"comment_post_ID=%d&comment_parent=%@&author=%@&email=%@&comment=%@";

NSString *post_str = [NSString stringWithFormat:post_content, self.postID, @"0", self.txtName.text, self.txtEmail.text, self.txtComment.text];

我试图使用你的代码,但我得到了一个错误“对不起,此评论无法发布”。你能帮我看看我自己的答案吗?