【问题标题】:Post comment to WordPress Blog from iPhone programmatically以编程方式从 iPhone 向 WordPress 博客发表评论
【发布时间】: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 上发表评论?

【问题讨论】:

    标签: iphone wordpress mobile


    【解决方案1】:

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

    【讨论】:

    • 您好,您的回答似乎是正确的。但我遇到的实际问题是网络上说“检测到重复评论;看起来你已经说过了!”虽然不是
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-08
    • 2011-10-11
    • 1970-01-01
    • 1970-01-01
    • 2012-12-30
    • 2021-04-16
    相关资源
    最近更新 更多