0
我做使用捲曲和PHP POST請求,代碼如下使用CURL PHP返回錯誤400的發佈請求? Systatically錯誤請求
<?php
$data = array("employeeAuth" => array("employeeNumber" => "376819"));
$data_post = json_encode($data);
echo $data_post;
$cSession = curl_init('http://10.40.4.170:80/xxxxxx/eeee/zzzz/kkkk');
curl_setopt($cSession,CURLOPT_CUSTOMREQUEST,"POST");
curl_setopt($cSession,CURLOPT_POSTFIELDS,$data_post);
curl_setopt($cSession,CURLOPT_RETURNTRANSFER,true);
curl_setopt($cSession,CURLOPT_HTTPHEADER,array(
"Content-Type:application/json;charset=UTF-8",
"Content-Length:". strlen($data_string)
));
$result=curl_exec($cSession);
curl_close($cSession);
echo $result;
?>
提到這個代碼後運行,我得到錯誤400從服務器響應,指出該請求在語法上是錯誤的。請讓我知道如果我做錯了什麼。
我怎麼可能這麼粗心:(:(....感謝一堆傑克...... !!這絕對是讓人搞砸了!榮譽!:) –
請務必接受答案 – Palpatim
@Palpatim完成! –