问下为什么我用postman post数据到服务器是可以的,但为什么我本地用http发起post请求就提示没有某一个参数?
我用laravel自带的HTTP客户端
public function test($data)
{
$url = $this->getDomain();
$data_string = json_encode($data);
$header = array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string)
);
return $this->response($url,$header,$data);
}
private function response($url,$request_header,array $data)
{
$response = Http::withHeaders($request_header)->withOptions(["verify"=>false])->asJson()->post($url,$data)->body();
print_r($response);
return $response;
}
然后就提示
Array(
[status_code] => 4007
[message] => 激活码不存在
)
帮忙问下我 这个 post请求的 application/json 格式对的吗?