我對iOS很新。我正試圖通過post方法將數據發送到PHP。在PHP中,它不能採用像$_POST['data']
這樣的數據,但它需要$_GET['data']
。我的iOS代碼如下。IOS發送post方法數據可以在php中作爲get方法訪問
NSString *strURL = [NSString stringWithFormat:@"http://example.com/app_respond_to_job?emp_id=%@&job_code=%@&status=Worker-Accepted&comment=%@",SaveID2,txtJobcode1,alertTextField.text];
NSURL *apiURL = [NSURL URLWithString:strURL];
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:apiURL];
[urlRequest setHTTPMethod:@"POST"];
NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:urlRequest delegate:self];
_receivedData = [[NSMutableData alloc] init];
[connection start];
NSLog(@"URL---%@",strURL);
有人可以解釋爲什麼,這將是非常有益的。