gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 21:17:30 25 4
gpt4 key购买 nike

我在本地主机服务器上安装了 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 服务器。如果你有一个公共(public)IP,那么把你的服务器的IP放在那里,否则通过WiFi将你的iPhone连接到与你的本地服务器相同的LAN,并使用该服务器的IP(我猜它会像192.168.. .).

关于iphone - 以编程方式从 iPhone 向 WordPress 博客发表评论,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9564276/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com