重點在CURLOPT_POSTFIELDS直接填入類似get的參數串,不用經過urlencode
然後CURLOPT_HTTPHEADER帶入array('Content-Type: application/x-www-form-urlencoded')
<?php
//
// A very simple PHP example that sends a HTTP POST to a remote site
//
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"http://xxxxxxxx.xxx/xx/xx");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,
"dispnumber=567567567&extension=6");
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
// receive server response ...
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec ($ch);
curl_close ($ch);
// further processing ....
if ($server_output == "OK") { ... } else { ... }
?>
--
轉自 https://stackoverflow.com/questions/18913345/curl-posting-with-header-application-x-www-form-urlencoded
文章標籤
全站熱搜
