zoukankan      html  css  js  c++  java
  • PHP对接阿里云物流信息接口

    public function  logistics($no,$type){
    $host = "https://wuliu.market.alicloudapi.com"; $path = "/kdi"; $method = "GET"; $appcode = "XXXXXXX"; $headers = array(); array_push($headers, "Authorization:APPCODE " . $appcode); $querys = "no=$no&type=$type"; //参数写在这里 $no要查询的快递单号,$type 那家的快递编码 阿里云的编码 自己对照 可不写 $bodys = ""; $url = $host . $path . "?" . $querys; $curl = curl_init(); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); curl_setopt($curl, CURLOPT_FAILONERROR, false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_HEADER, false); if (1 == strpos("$".$host, "https://")){ curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); } curl_setopt($curl, CURLOPT_POSTFIELDS, $bodys); $res=curl_exec($curl); $data=json_decode($res); if($data->status==0){ $wuliu=$data->result->list; return ['code'=>2000,'msg'=>'成功','data'=>$wuliu]; }else{ return ['code'=>4000,'msg'=>'暂无物流信息']; }
    }
  • 相关阅读:
    PHP和JS判断手机还是电脑访问
    apache 一个站点配置多个域名
    拾遗
    提高工作效率的工具
    PHP urlencode
    JS encodeURI和encodeURIComponent
    Linux实践:ELF文件格式分析
    Linux实践:文件破解
    Linux实践:模块
    Linux内核学习期末总结(网课)
  • 原文地址:https://www.cnblogs.com/cyk2/p/15337238.html
Copyright © 2011-2022 走看看