本文实例讲述了php查询快递信息的方法。分享给大家供大家参考。具体如下:
这里使用快递100物流查询
官方文档中只能返回html的接口 也可以返回json
php代码如下:
商品查询功能提供了一个快速查看商品的途径。商品查询分为基本查询和高级查询。基本查询:提供关键字和商品大类两种条件的查询,用户可以只填写关键字或者选择商品大类或者关键字和商品大类都填写来查询商品。高级查询:提供关键字,商品大类,商品小类,商品价格范围四种条件的查询,用户可以任意填写其中一种或几种的查询条件来查询想要了解的商品信息。商品查询功能大大的方便了用户,提高了网站的用户体验。(5)帮助系统模块
0
代码如下:
/**
* @desc 获取快递信息
* @param string $code 快递编码
* @param string $invoice 快递单号
* @return mixed $result(
'status','info','state','data'
)
*/
function getExpressDelivery($code,$invoice){
$result = array('status'=>0,'info'=>'未知错误');
$url = "http://m.kuaidi100.com/query?type={$code}&postid={$invoice}&id=1&valicode=&temp=".rand(1,710);
$body = file_get_contents($url); //FIXME
$body = json_decode($body,true);
$result['status'] = $body['status'] == 200 ? 1 : 0;
$result['info'] = $body['message'];
isset($body['data']) && ($result['state']=$body['state']) && ($result['data'] = $body['data']) ;
return $result;
}
希望本文所述对大家的php程序设计有所帮助。
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号