如何从这个文档中创建php cURL



如何从本文档中创建PHP cURL,下面是cURL的原始文本

curl --location --request POST '/serviceRates' 
--header 'Content-Type: application/json' 
--header 'access-key-id: ***' 
--header 'secret-access-key: ***' 
--data-raw '{
"origin": "31.72.01",
"destination": "31.72.55",
"weight": 2000
}'
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, '/serviceRates');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
$headers = array();
$headers[] = 'Content-Type: application/json';
$headers[] = 'Access-Key-Id: ***';
$headers[] = 'Secret-Access-Key: ***';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close($ch);

最新更新