• php快递单号查询源码


    贴下记录下php查询快递单号的源码,能查询各种快递的快递单号记录,中通、圆通快递、顺丰快递等都不是问题。只需要在

    爱快递(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 = 'xxx';  爱快递申请
        $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;
    }
    

      

  • 相关阅读:
    计算机中的进制和编码
    操作系统简史
    电脑结构和CPU、内存、硬盘三者之间的关系
    电脑简史
    使用开源my-deploy工具实现开发环境的代码自动化部署
    使用Let’s Encrypt创建nginx免费SSL证书
    VM ESXI 服务器虚拟化资料积累
    python mysql连接函数
    python日期格式转换小记
    Python模块学习
  • 原文地址:https://www.cnblogs.com/zhangjin001/p/3731173.html
Copyright © 2020-2023  润新知