2
私は自分のlocalhostサーバーにWordPressブログをインストールし、rss経由でブログをブラウズするiPhoneアプリも作成しました。私はプログラムでこのコードを使ってコメントを投稿しようとしました。WordPressブログにiPhoneからプログラムで投稿する
#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", @"[email protected]", @"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からコメントを投稿するにはどうすればよいですか?
こんにちは、あなたの答えは正しいようです。しかし、実際に私が会う問題は、ウェブでは「重複したコメントが検出されました;あなたがすでに言ったように見えます」ということです。それはありません –