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完成! –