/** * 返回接口數據 " /> 亚洲精品日韩一,欧美性xxxx极品hd欧美风情,欧美影院精品

色尼玛亚洲综合影院,亚洲3atv精品一区二区三区,麻豆freexxxx性91精品,欧美在线91

php實現12306余票查詢、價格查詢示例

復制代碼 代碼如下:
<?php
/**
 * 車票接口類
 *
 * @author chepiao100
 *
 */
class chepiao100

 /**
  * 接口地址
  * @var string
  */
 private $_apiurl = 'http://www.chepiao100.com/api/';

  /**
   * 返回接口數據
   *
   * @param string $method 接口方法
   * @param array $param 請求參數
   * @return mixed
  */
  function getData($method, $param)
  {
    $post = http_build_query($param);
    $html = $this->fetch_html($this->_apiurl.$method, $post);
    $jsonArr = json_decode($html, TRUE);
    if ( $jsonArr['errMsg'] == 'Y') {
      return $jsonArr['data'];
    } else {
      return $jsonArr['errMsg'];
    }
  }

  /**
   * 請求HTTP
   *
   * @param string $url
   * @param string $post
   * @return mixed
   */
  function fetch_html($url, $post)
  {
   $ch = curl_init($url);
   curl_setopt($ch, CURLOPT_TIMEOUT, 60);
   curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
   curl_setopt($ch, CURLOPT_POST, true);
   //curl_setopt($ch, CURLOPT_PROXY, 'http://10.100.10.100:3128');
   curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
   $html = curl_exec($ch);
   curl_close($ch);
   return $html;
  }
}
/** End class of chepiao100 **/

php技術php實現12306余票查詢、價格查詢示例,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 嘉祥县| 灌阳县| 饶河县| 普宁市| 开封县| 栖霞市| 信阳市| 海淀区| 呼玛县| 民权县| 太白县| 闻喜县| 财经| 庆元县| 宕昌县| 济阳县| 阳新县| 中牟县| 大悟县| 杨浦区| 安福县| 钟祥市| 清丰县| 逊克县| 乌拉特中旗| 滕州市| 屏南县| 乌鲁木齐县| 包头市| 泰州市| 于田县| 英山县| 迁西县| 龙岩市| 介休市| 东台市| 靖宇县| 漳平市| 安徽省| 浮山县| 宁海县|