/** * 返回接口數據 " /> 欧美精品一区二区久久久,手机在线观看av网站,日韩三级电影视频

色尼玛亚洲综合影院,亚洲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余票查詢、價格查詢示例,轉載需保留來源!

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

主站蜘蛛池模板: 柘荣县| 洞口县| 加查县| 惠安县| 台安县| 江北区| 东港市| 衡阳县| 敦化市| 郑州市| 松滋市| 安多县| 新乡县| 南召县| 鄂伦春自治旗| 佛山市| 东莞市| 苏尼特左旗| 东乡族自治县| 仪陇县| 贺兰县| 汤阴县| 黑山县| 海盐县| 寿阳县| 桦甸市| 金阳县| 夏河县| 眉山市| 涡阳县| 遂昌县| 天台县| 邮箱| 海宁市| 尚义县| 佛学| 治县。| 岑巩县| 阳曲县| 黎川县| 贺州市|