首页 快递查询 快递查询示例代码 快递查询[PHP]
  • 示例代码

本代码示例是基于PHP的六派数据接口进行数据请求 快递实时查询 API服务请求的代码示例,使用前你需要:

①:通过https://www.6api.net/api/express/ 申请API服务

以下是完整代码示例:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
require_once("curl.func.php");
 
$method = "POST";
$url = "http://open.6api.net/express/search";
$headers = NULL;
$params = array
    "appkey" => "yourappsecret",
    "cpCode" => "JD",
    "mailNo" => "JDVF01604405153",
    "tel" => "参数3",
    "orderType" => "desc",
    "logisticsWarn" => "0"
);
$result = api_curl($method, $url, $headers, $params);
if ($result) {
    $body = json_decode($result["body"], TRUE);
    $status_code = $body["status"];
    if ($status_code == "200") {
        var_dump($body["result"]);
    }else
        var_dump($body);
}else 
    echo "发送请求失败";