Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
以编程方式从iPhone向WordPress博客发表评论_Iphone_Wordpress_Mobile - Fatal编程技术网

以编程方式从iPhone向WordPress博客发表评论

以编程方式从iPhone向WordPress博客发表评论,iphone,wordpress,mobile,Iphone,Wordpress,Mobile,我在本地主机服务器上安装了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=%@" NSStrin

我在本地主机服务器上安装了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发布评论?

首先,如果您在iPhone上运行的代码中使用“localhost”,那么“localhost”将指的是iPhone而不是web服务器。将服务器的IP放在那里,如果您有一个公共IP,则通过WiFi将您的iPhone连接到与本地服务器相同的LAN,并使用该服务器的IP(我猜可能是192.168…。

您好,您的答案似乎是正确的。但我遇到的实际问题是网络上说“检测到重复评论;看起来你好像已经说过了!”尽管事实并非如此