【发布时间】:2012-03-05 09:27:05
【问题描述】:
我在我的 localhost 服务器上安装了 WordPress 博客,还制作了一个 iPhone 应用程序来通过 rss 浏览博客。我尝试使用此代码以编程方式发表评论。
#define post_url @"http://localhost/web-wp/wp-comments-post.php"
#define post_content @"comment_post_ID=%@&comment_parent=%@&author=%@&email=%@&comment=%@"
NSString *post_str = [NSString stringWithFormat:post_content, @"1", @"0", @"Viet", @"vietnt88@gmail.com", @"test. comment written on mobile"];
NSData *data = [post_str dataUsingEncoding:NSUTF8StringEncoding];
NSURL * url = [NSURL URLWithString:post_url];
NSMutableURLRequest *req = [[NSMutableURLRequest alloc] initWithURL:url];
[req setHTTPMethod:@"POST"];
[req setHTTPBody:data];
NSURLResponse *response;
NSError *err;
[NSURLConnection sendSynchronousRequest:req returningResponse:&response error:&err];
当用户未登录时,我需要此代码才能工作。我该如何实现?
如何在 iPhone 上发表评论?
【问题讨论】: