PHP http 请求 GuzzleHttp 执行 POST 请求 以 form_params 参数请求


$url = 'http://localhost:8090/es/search';
$client = new Client();
$headers = ['Content-Type' => 'application/x-www-form-urlencoded'];
$response = $client->request('POST', $url, [
    'form_params' => ['search'=>'pdf'], 
    'headers' => $headers,
    'verify' => false, 
    'allow_redirects' => ['strict' => true]
]);
$articleSize = $response->getHeaderLine('articleSize');
$contents = $response->getBody()->getContents();