php查询快递信息

$code 		= 'shunfeng';
$invoice 	= '952255884068';
$test 		= getExpressDelivery($code,$invoice);

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;
}    

 

posted on 2017-02-28 17:47  爱吃柠檬不加糖  阅读(296)  评论(0编辑  收藏  举报

导航