GuzzleHttp cURL error 7 报错
代码如下
$client =new Client;
$api='https://www.xxxx.com/api/Auth/PostToken';
$response=$client->request('POST',$api,[
'json'=>[
'UserName'=> 'clixxxt_cxxtials',
'ClientId'=>'client',
'Password'=>'xxxx'
],
'headers' => [
'Content-type'=> 'application/json']
]);
$response=$client ->post($api);
dd($response);
总是报cURL error 7: Failed connect to www.xxxx.com:443; Connection timed out (see http://curl.haxx.se/libcurl/c/libcurl-errors.html),请教各位大佬,问题出在哪里?
这样应该是通 的吧
关于 LearnKu
你是想传 json 数据吗?
guzzle 那种传 json 的官方写法有问题,改用这种:
$client = new Client(POST, URL,[
'body' => json_encode($value, JSON_UNESCAPED_UNICODE),
'headers' => ['content-type' => 'application/json']
]);
试试~