-
注釋:Ixudra\Curl的安裝請(qǐng)參考Ixudra\Curl官網(wǎng)
-
使用curl 發(fā)送post請(qǐng)求
$curl = \Curl::to($url)->to($url)
->asJsonRequest()
->withData([
'center_ip' => $center_ip,
'machine_code' => $hcode,
'action' => $action,
'node_uuid' => $nodeUuid
])
->withTimeout(60)
->asJsonResponse()
->returnResponseObject();
$res = $curl->post();
-
通過(guò)curl 使用SSL證書(shū)進(jìn)行通信
$certfile = 'client.crt';
$keyfile= 'client.key';
$curl = \Curl::to('https://'.$url)
->withOption('SSL_VERIFYHOST', false)
->withOption('SSLKEY', $keyfile)
->withOption('SSLCERT', $certfile);
$res = $curl->post();
return in_array($res->status, [200, 201, 204]);