1//this send application/x-www-form-urlencoded
2 function httpPostXform($url, $data) {
3 $curl = curl_init($url);
4 curl_setopt($curl, CURLOPT_POST, true);
5 curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
6 curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
7 curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
8 $response = curl_exec($curl);
9 curl_close($curl);
10 return $response;
11}
12$r = httpPostXform("https://www.somesite.com",array("user_id"=>10,"sex"=>"male"));