CURL:主机名和端口之后的路径

时间:2018-06-01 02:04:01

标签: php curl php-curl

我想使用PHP中的curl将JSON数据发送到http://localhost:3000/certificates

以下是我的工作:

$url = 'http://localhost';
$ch = curl_init($url);
$jsonData = array(
    'certno' => 'AB1234',
    'issueDate' => 'asdasd',
    'type' => 'asdasdasd'
);
$jsonDataEncoded = json_encode($jsonData);
curl_setopt($ch, CURLOPT_PORT, 3000); 
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonDataEncoded);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); 
$result = curl_exec($ch);

如何添加/证书?我不能简单地将它放在网址http://localhost/certificates中吗?

0 个答案:

没有答案