php快递单号查询接口使用示例

时间:2023-10-25 07:39:55 

通过本接口可以查询圆通快递、申通快递、ems快递、韵达快递等快递单号查询信息,无需其他额外开发,非常方便
首先到www.aikuaidi.cn上注册个账号,使用key!


<?php
/**
 * 查询物流信息
 */
define('IN_ECS', true);

require(dirname(__FILE__) . '/includes/init.php');

if ($id = intval($_REQUEST['id'])) {
    $sql_select = 'SELECT consignee,mobile,tel,tracking_sn,shipping_code,shipping_name FROM '.
        $GLOBALS['ecs']->table('order_info')." WHERE order_id=$id";
    $order_info = $GLOBALS['db']->getRow($sql_select);

    // 快递公司code映射
    $shipping_code = array (
        'ems'         => 'ems',
        'ems2'        => 'ems',
        'sto_express' => 'zjs',
        'sto_nopay'   => 'zjs',
        'zto'         => 'zhongtong',
        'sto'         => 'shentong',
        'yto'         => 'yuantong',
        'sf'          => 'shunfeng',
        'emssn'       => 'ems',
        'sf2'         => 'shunfeng',
        'yunda'       => 'yunda',
    );

    $logistics_code = $shipping_code[$order_info['shipping_code']] ? $shipping_code[$order_info['shipping_code']] : $order_info['shipping_code'];
    $aikuaidi_key = 'xxxxxxx';

    $logistics_url = "http://www.aikuaidi.cn/rest/?key=$aikuaidi_key&order={$order_info['tracking_sn']}&id=$logistics_code&ord=asc&show=html";

    $logistics_info = file_get_contents($logistics_url);
    //var_dump($logistics_info);

    //$logistics_info = iconv('gb2312', 'UTF-8', $logistics_info);

    echo <<<EOF
        <span>收货人:<strong>{$order_info['consignee']}</strong></span>
        <span>联系电话:<strong>{$order_info['mobile']} // {$order_info['tel']}</strong></span>
        <span>配送:<strong>{$order_info['shipping_name']}</strong></span>
        <span>运单号:<strong>{$order_info['tracking_sn']}</strong></span><br><br>
EOF;
    echo $logistics_info;

    echo "<br><br><a href='$logistics_url' target='_self'>点我点我</a>";
    //exit;
}

标签:php,快递
0
投稿

猜你喜欢

  • MySQL Select语句是如何执行的

    2024-01-22 20:05:44
  • 如何解决AJAX中跨域访问出现'没有权限'的错误

    2008-09-11 17:20:00
  • Go语言递归函数的具体实现

    2023-08-05 02:35:32
  • Pytorch实现图像识别之数字识别(附详细注释)

    2022-04-08 08:12:54
  • MySQL中随机生成固定长度字符串的方法

    2024-01-12 13:04:20
  • mysql通过查看跟踪日志跟踪执行的sql语句

    2024-01-28 00:56:10
  • Sql学习第一天——SQL 练习题(建表/sql语句)

    2024-01-22 05:44:39
  • Mysql如何对json数据进行查询及修改

    2024-01-14 06:29:56
  • 快速上手基于Anaconda搭建Django环境的教程

    2021-07-02 22:07:13
  • pycharm中代码回滚到指定版本的两种实现方法(附带截图展示)

    2021-11-26 22:51:18
  • python编程使用协程并发的优缺点

    2023-07-20 12:11:45
  • mysql ERROR 1045 (28000)问题的解决方法

    2024-01-16 23:24:32
  • python如何代码集体右移

    2023-07-08 01:34:28
  • python 查找字符串是否存在实例详解

    2023-09-22 21:31:17
  • Python运算符的应用超全面详细教程

    2023-08-20 18:24:56
  • Go语言学习之反射的用法详解

    2023-06-16 06:40:40
  • python学习必备知识汇总

    2022-01-05 10:26:23
  • keras获得model中某一层的某一个Tensor的输出维度教程

    2023-12-15 11:28:54
  • js实现限定范围拖拽的示例

    2024-04-29 13:38:55
  • 基于Python利用Pygame实现翻转图像

    2021-05-20 00:05:08
  • asp之家 网络编程 m.aspxhome.com