php curl post application/x-www-form-urlencoded
//this send application/x-www-form-urlencoded
function httpPostXform($url, $data) {
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
$response = curl_exec($curl);
curl_close($curl);
return $response;
}
$r = httpPostXform("https://www.somesite.com",array("user_id"=>10,"sex"=>"male"));