This interface can be used to query the information of express waybills such as yuantong Express, Shentong express, EMS express, and yunda Express, which is convenient without additional development.
Register an account on www.aikuaidi.cn and use the key!
Copy codeThe Code is as follows:
<? Php
/**
* Query Logistics Information
*/
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 );
// Courier company code ing
$ Shipping_code = array (
'EMS' => 'EMS ',
'Ems2' => 'EMS ',
'Sto _ express '=> 'zjs ',
'Sto _ nopa' => 'zjs ',
'Zto' => 'zhongtong ',
'Sto '=> 'shentong ',
'Yto '=> 'yuyun G ',
'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> receiver: <strong >{$ order_info ['consignee']} </strong> </span>
<Span> contact number: <strong> {$ order_info ['mobile']} // {$ order_info ['tel ']} </strong> </span>
<Span> delivery: <strong >{$ order_info ['shipping _ name']} </strong> </span>
<Span> waybill number: <strong >{$ order_info ['tracking _ sn '] }</strong> </span> <br>
EOF;
Echo $ logistics_info;
Echo "<br> <a href = '$ logistics_url 'target =' _ self '> click me </a> ";
// Exit;
}