POSTメソッドで文字列を渡したい..
文字列は@"functionName=getCourses_by_category&json={"course_cat_id":"8"}"
POSTメソッドで文字列を渡したい..
文字列は@"functionName=getCourses_by_category&json={"course_cat_id":"8"}"
POSTデータの送信方法に関するAppleのドキュメントから:
NSString *bodyData = @"functionName=getCourses_by_category&json={\"course_cat_id\":\"8\"}";
NSMutableURLRequest *postRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://www.apple.com"]];
// Set the request's content type to application/x-www-form-urlencoded
[postRequest setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
// Designate the request a POST request and specify its body data
[postRequest setHTTPMethod:@"POST"];
[postRequest setHTTPBody:[NSData dataWithBytes:[bodyData UTF8String] length:[bodyData length]]];
// Initialize the NSURLConnection and proceed as usual