/** * 返回接口數據 " /> 亚洲一区激情,久久超碰亚洲,天天综合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余票查詢、價格查詢示例,轉載需保留來源!

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

主站蜘蛛池模板: 庄浪县| 墨竹工卡县| 衡南县| 宜黄县| 绥棱县| 朔州市| 通州区| 邵阳县| 陵川县| 甘肃省| 廉江市| 集安市| 江门市| 双江| 盐亭县| 滦南县| 婺源县| 新丰县| 张北县| 濉溪县| 如皋市| 郸城县| 全南县| 益阳市| 乾安县| 霍邱县| 弥渡县| 伊宁市| 康定县| 大冶市| 靖江市| 通河县| 库尔勒市| 道真| 江都市| 泗阳县| 博兴县| 祁东县| 平远县| 陇川县| 寻甸|