zoukankan      html  css  js  c++  java
  • 根据物流号查看物流信息

    <?php
    /**
    * Express.class.php 快递查询类 v1.0
    *
    * @copyright 福星高照
    * @license http://www.25531.com
    * @lastmodify 2014-08-22
    */
    class Express
    {
    /*
    * 网页内容获取方法
    */
    private function getcontent($url){
    $oCurl = curl_init();
    if(stripos($url,"https://")!==FALSE){
    curl_setopt($oCurl, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($oCurl, CURLOPT_SSL_VERIFYHOST, FALSE);
    }
    curl_setopt($oCurl, CURLOPT_URL, $url);
    curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, 1 );
    $sContent = curl_exec($oCurl);
    $aStatus = curl_getinfo($oCurl);
    curl_close($oCurl);
    if(intval($aStatus["http_code"])==200){
    return $sContent;
    }else{
    return false;
    }
    }

    /*
    * 获取对应名称和对应传值的方法
    */
    private function expressname($order)
    {
    $name = json_decode($this->getcontent("http://www.kuaidi100.com/autonumber/auto?num={$order}"), true);
    $result = $name[0]['comCode'];
    if (empty($result)) {
    return false;
    } else {
    return $result;
    }
    }

    /*
    * 返回$data array 快递数组查询失败返回false
    * @param $order 快递的单号
    * $data['ischeck'] ==1 已经签收
    * $data['data'] 快递实时查询的状态 array
    */
    public function getorder($order)
    {
    $keywords = $this->expressname($order);
    if (!$keywords) {
    return false;
    } else {
    $result = $this->getcontent("http://www.kuaidi100.com/query?type={$keywords}&postid={$order}");
    $data = json_decode($result, true);
    return $data;
    }
    }
    }
    ?>

  • 相关阅读:
    代理
    博客园主题
    JS_1
    脚本语言
    Hadoop生态体系
    Hadoop序列化程序报错
    46. 全排列
    1038 Recover the Smallest Number (30分)
    1064 Complete Binary Search Tree (30分)
    1034 Head of a Gang (30分)
  • 原文地址:https://www.cnblogs.com/timothy-lai/p/5112724.html
Copyright © 2011-2022 走看看