Home >Backend Development >PHP Tutorial >Example of using PHP express tracking number query interface_PHP tutorial

Example of using PHP express tracking number query interface_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:30:322107browse

Through this interface, you can query express tracking information such as YTO Express, STO Express, EMS Express, Yunda Express, etc. No additional development is required, which is very convenient
First, register an account on www.aikuaidi.cn and use key !

Copy code The code is as follows:

/**
* Check 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);

// Express company code mapping
$shipping_code = array (
'ems' => 'ems',
'ems2' => 'ems',
'sto_express' = > 'zjs',
'sto_nopay' => 'zjs',
'zto' => 'zhongtong',
'sto' => 'shentong',
       'yto ' 'sf' => 'yuantong',
'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);

< span>Contact number:{$order_info['mobile']} // {$order_info['tel']}

           Delivery: < strong>{$order_info['shipping_name']}

                                                                                                                      ​


EOF;
echo $logistics_info;

echo "

Click me click me";
//exit;
}




http://www.bkjia.com/PHPjc/765160.html

www.bkjia.com

http: //www.bkjia.com/PHPjc/765160.htmlTechArticleYou can query YTO Express, STO Express, ems Express, Yunda Express and other express delivery tracking number information through this interface, no need For other additional developments, it is very convenient to register on www.aikuaidi.cn first...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn