这篇文章主要介绍了PHP查询快递信息的方法,实例分析了通过第三方平台接口查询快递信息的技巧,具有一定参考借鉴价值,需要的朋友可以参考下
本文实例讲述了PHP查询快递信息的方法。分享给大家供大家参考。具体如下:
这里使用快递100物流查询
官方文档中只能返回html的接口 也可以返回json
php代码如下:
复制代码 代码如下:
/**
* @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程序设计有所帮助。
,
Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

WebStorm Mac version
Useful JavaScript development tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

Zend Studio 13.0.1
Powerful PHP integrated development environment

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function
