aliyun-wuliu repository

runphp 6508dc84d9 chore(deps): 升级 PHP 和 six-shop/core 依赖版本 há 3 meses atrás
database eb0f7afd8a fix(wuliu): 修复数据库迁移文件中的列类型定义 há 5 meses atrás
route 97cb1a6d7a feat(aliyun-wuliu): 增加物流查询权限控制和频率限制 há 5 meses atrás
src 65eeb2e9af fix(wuliu):修复物流更新时间判断逻辑 há 4 meses atrás
test 65eeb2e9af fix(wuliu):修复物流更新时间判断逻辑 há 4 meses atrás
.gitignore e1141c0097 feat(extensions): 添加阿里云物流扩展 há 7 meses atrás
LICENSE 4466dcd0b4 Initial commit há 7 meses atrás
README.md e1141c0097 feat(extensions): 添加阿里云物流扩展 há 7 meses atrás
composer.json 6508dc84d9 chore(deps): 升级 PHP 和 six-shop/core 依赖版本 há 3 meses atrás
config.php e1141c0097 feat(extensions): 添加阿里云物流扩展 há 7 meses atrás
info.php 8e5126b081 fix: 修改扩展ID命名 há 6 meses atrás

README.md

全国快递物流查询

扩展说明

参考: https://market.aliyun.com/apimarket/detail/cmapi021863#sku=yuncode15863000017


<?php
error_reporting(E_ALL || ~E_NOTICE);
$host = "https://wuliu.market.alicloudapi.com";//api访问链接
$path = "/kdi";//API访问后缀
$method = "GET";
$appcode = "你自己的AppCode";//开通服务后 买家中心-查看AppCode
$headers = array();
array_push($headers, "Authorization:APPCODE " . $appcode);
$querys = "no=780098068058&type=zto";  //参数写在这里
$bodys = "";
$url = $host . $path . "?" . $querys;

$curl = curl_init();
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_FAILONERROR, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, true);
if (1 == strpos("$" . $host, "https://")) {
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
}
$out_put = curl_exec($curl);

$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);

list($header, $body) = explode("\r\n\r\n", $out_put, 2);
if ($httpCode == 200) {
    print("正常请求计费(其他均不计费)<br>");
    print($body);
} else {
    if ($httpCode == 400 && strpos($header, "Invalid Param Location") !== false) {
        print("参数错误");
    } elseif ($httpCode == 400 && strpos($header, "Invalid AppCode") !== false) {
        print("AppCode错误");
    } elseif ($httpCode == 400 && strpos($header, "Invalid Url") !== false) {
        print("请求的 Method、Path 或者环境错误");
    } elseif ($httpCode == 403 && strpos($header, "Unauthorized") !== false) {
        print("服务未被授权(或URL和Path不正确)");
    } elseif ($httpCode == 403 && strpos($header, "Quota Exhausted") !== false) {
        print("套餐包次数用完");
    } elseif ($httpCode == 403 && strpos($header, "Api Market Subscription quota exhausted") !== false) {
        print("套餐包次数用完,请续购套餐");
    } elseif ($httpCode == 500) {
        print("API网关错误");
    } elseif ($httpCode == 0) {
        print("URL错误");
    } else {
        print("参数名错误 或 其他错误");
        print($httpCode);
        $headers = explode("\r\n", $header);
        $headList = array();
        foreach ($headers as $head) {
            $value = explode(':', $head);
            $headList[$value[0]] = $value[1];
        }
        print($headList['x-ca-error-message']);
    }
}