Fifth, the Express query
1, interface specification
Express check provides third-party platform for many, such as courier 100, data aggregation, Baidu cloud apistore, Ali cloud, Tencent cloud, Jingdong Vientiane and so on.
Here to aggregate data platform, for example: Interface page: https://www.juhe.cn/docs/api/id/43
** interface address: ** http: //v.juhe.cn/exp/index
** Returns the format: ** json / xml
** Request ways: ** http post / get
Required Request Parameters: com Express ID; NO express orders; key authorization key
** request example: ** http: //v.juhe.cn/exp/index com = zto & no = 73115984252335 & key = ac2dde994cc76d4f15738f7f97af7ca4?
2, the use of project
api controller module index method kuaidi
public function kuaidi()
{
//接口地址
$url = "http://v.juhe.cn/exp/index?com=zto&no=73115984252335&key=ac2dde994cc76d4f15738f7f97af7ca4";
//请求方式 get post
//请求参数
$params = [
'com' => 'zto',
'no' => '73115984252335',
'key' => 'ac2dde994cc76d4f15738f7f97af7ca4'
];
//发送请求
$res = curl_request($url, true, $params);
if(!$res){
echo '请求失败';die;
}
//解析结果
$arr = json_decode($res, true);
//查询失败
if($arr['resultcode'] != 200){
echo $arr['reason'];die;
}
//查询成功,展示信息
$list = $arr['result']['list'];
echo '时间 ------------------------ 物流信息<br>';
foreach($list as $v){
echo $v['datetime'], '------------------------', $v['remark'], '<br>';
}
}
Display of results: