您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

php代码实现12306余票查询、价格查询功能

2024/3/5 23:44:54发布20次查看
12306余票查询、价格查询功能的实现,本篇将做出相关的介绍。
<?php/** * 车票接口类 * * @author chepiao100 * */class chepiao100{ /** * 接口地址 * @var string */ private $_apiurl = 'https://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, 'https://10.100.10.100:3128'); curl_setopt($ch, curlopt_postfields, $post); $html = curl_exec($ch); curl_close($ch); return $html; }}/** end class of chepiao100 **/
本篇文章介绍了12306余票查询、价格查询功能,并且使用代码实现了相关的功能,更多相关内容请关注。
相关推荐:
介绍php快速导出table数据相关教程
讲解php预定义接口之arrayaccess的使用方法
介绍php文件命名、类和方法的命名、变量的命名等规范
以上就是php代码实现12306余票查询、价格查询功能的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product