亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

php實(shí)現(xiàn)12306余票查詢(xún)、價(jià)格查詢(xún)示例

 更新時(shí)間:2014年04月17日 10:00:22   作者:  
這篇文章主要介紹了php實(shí)現(xiàn)12306余票查詢(xún)、價(jià)格查詢(xún)示例的相關(guān)資料

復(fù)制代碼 代碼如下:

<?php
/**
 * 車(chē)票接口類(lèi)
 *
 * @author chepiao100
 *
 */
class chepiao100

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

  /**
   * 返回接口數(shù)據(jù)
   *
   * @param string $method 接口方法
   * @param array $param 請(qǐng)求參數(shù)
   * @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'];
    }
  }

  /**
   * 請(qǐng)求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 **/

相關(guān)文章

最新評(píng)論