-2

POSTメソッドで文字列を渡したい..

文字列は@"functionName=getCourses_by_category&json={"course_cat_id":"8"}"

4

1 に答える 1

0

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
于 2013-04-05T03:36:11.047 に答える