欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

PHP查詢快遞信息的方法

 更新時(shí)間:2015年03月07日 12:03:24   作者:冰糖710  
這篇文章主要介紹了PHP查詢快遞信息的方法,實(shí)例分析了通過(guò)第三方平臺(tái)接口查詢快遞信息的技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下

本文實(shí)例講述了PHP查詢快遞信息的方法。分享給大家供大家參考。具體如下:

這里使用快遞100物流查詢
官方文檔中只能返回html的接口 也可以返回json

php代碼如下:

復(fù)制代碼 代碼如下:
/**
 * @desc 獲取快遞信息
 * @param string $code 快遞編碼
 * @param string $invoice 快遞單號(hào)
 * @return mixed $result(
      'status','info','state','data'
   )
 */
function getExpressDelivery($code,$invoice){
    $result = array('status'=>0,'info'=>'未知錯(cuò)誤');
    $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;
}

希望本文所述對(duì)大家的php程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論