本页面提供长沙市同城快递的实时价格查询,数据来源为各快递公司官方网站。
查询方式:
-
选择快递公司
-
输入寄件地址和收件地址
-
输入包裹重量(单位:公斤)
-
点击“查询价格”按钮
查询结果:
查询结果:
";echo "";echo "";echo "";echo "
快递公司
|
寄件地址
|
收件地址
|
包裹重量
|
价格
|
{$company}
|
{$from}
|
{$to}
|
{$weight}公斤
|
{$price}元
|
";}function get_price($companyCode, $from, $to, $weight) {// 请求快递公司接口获取价格$url = 'https://www.kuaidi100.com/pricequery/';$data = ['type' => $companyCode,'from' => $from,'to' => $to,'weight' => $weight,'volume' => '','callbackurl' => '',];$options = ['http' => ['header' => "Content-Type: application/json\r\n",'method' => 'POST','content' => json_encode($data),],];$context = stream_context_create($options);$response = file_get_contents($url, false, $context);$result = json_decode($response, true);// 返回价格if ($result['status'] == '200') {return $result['price'];} else {return '暂无价格';}}?>