网站地图    收藏   

主页 > 后端 > 微信开发 >

方倍微信公众平台开发(43)火车时刻查询 - 微信

来源:自学PHP网    时间:2015-04-14 12:38 作者: 阅读:

[导读] 微信公众平台开发 微信公众平台开发模式 企业微信公众平台 火车票接口 列车时刻接口火车车次查询作者:方倍工作室原文:http: www cnblogs com txw1958 p weixin-43-train html一、火车查询接口在...

一、火车查询接口

在百度找到去哪儿的接口

http://train.qunar.com/qunar/checiInfo.jsp?ex_track=&q=t110&format=json&cityname=123456&ver=1373813217828&callback=XQScript_5

q为车次
ver为当前毫秒时间戳
cityname按车次查询时为123456

 

二、结果数据

string(3634) "XQScript_5(
{"ticketInfo":
{"2192\/2193":[
{"pr":88.5,"type":"硬座"},
{"pr":183.5,"type":"硬卧中"},
{"pr":304.5,"type":"软卧下"}]},"trainInfo":
{"2192\/2193":
{"arriCity_py":"zhengzhou","istmp":false,"code":"2192\/2193","deptCity_py":"wenzhou","arriStation":"郑州","arriCity":"郑州","trainType":"普快","deptTime":"13:52","deptStation":"温州","deptCity":"温州","arriTime":"14:20","interval":"1天28分"}},"trainScheduleHead":["站次","站名","日期","到达时间","开车时间","停车时间","里程","硬座","软座","二等软座","一等软座","硬卧上\/中\/下","软卧上\/下"],"extInfo":
{"allMileage":"1496公里","allTime":"1天28分"},"trainScheduleBody":[
{"mxl":34521376777470,"content":[83,"长兴南","第一天","23:25","23:29","4分","575公里",110,"0","0","0","154\/157\/160","204\/210"]},
{"content":[34,"武义","第一天","17:31","17:33","2分","222公里",46.5,"0","0","0","80.5\/83.5\/85.5","107.5\/111.5"]},
{"content":[17,"丽水","第一天","16:00","16:03","3分","136公里",24.5,"0","0","0","58.5\/61.5\/63.5","81.5\/85.5"]},
{"content":[62,"芜湖","第二天","01:53","02:00","7分","753公里",99,"0","0","0","153\/157\/161","217\/224"]},
{"content":[24,"宣城","第二天","00:55","01:03","8分","689公里",57,"0","0","0","107\/110\/114","165\/173"]},
{"content":[45,"德清西","第一天","22:27","22:37","10分","517公里",70,"0","0","0","111\/113\/116","156\/161"]},
{"content":[55,"缙云","第一天","16:35","16:37","2分","168公里",63.5,"0","0","0","97.5\/100.5\/102.5","122.5\/126.5"]},
{"content":[93,"永康","第一天","17:08","17:11","3分","201公里",104.5,"0","0","0","138.5\/141.5\/143.5","164.5\/168.5"]},
{"content":[76,"青田","第一天","14:44","14:48","4分","57公里",78,"0","0","0","112\/115\/117","131.5\/135.5"]},
{"content":[38,"温州","-","起点站","13:52","-",0,37,0,0,0,"37\/37\/37","37\/37"]},
{"content":[51,"杭州","第一天","21:30","21:44","14分","449公里",73.5,"0","0","0","110.5\/113.5\/115.5","150.5\/155.5"]},
{"mxl":16076029707508,"content":[58,"亳州","第二天","10:15","10:22","7分","1219公里",114.5,"0","0","0","190.5\/196.5\/202.5","288.5\/300.5"]},
{"mxl":7253046021614,"content":[79,"淮南","第二天","05:49","05:55","6分","989公里",125.5,"0","0","0","191.5\/196.5\/201.5","274.5\/284.5"]},
{"mxl":19294423176992,"content":[69,"开封","第二天","13:10","13:24","14分","1424公里",131.5,"0","0","0","216.5\/223.5\/230.5","328.5\/341.5"]},
{"content":[100,"巢湖","第二天","02:53","02:59","6分","830公里",140,"0","0","0","198\/202\/207","269\/278"]},
{"content":[41,"合肥","第二天","03:54","04:14","20分","894公里",82,"0","0","0","142\/146\/151","216\/225"]},
{"content":[13,"义乌","第一天","19:41","19:46","5分","310公里",28.5,"0","0","0","62.5\/65.5\/67.5","93.5\/97.5"]},
{"content":[20,"阜阳","第二天","07:50","08:20","30分","1115公里",71.5,"0","0","0","143.5\/148.5\/154.5","234.5\/245.5"]},
{"content":[96,"商丘","第二天","11:17","11:21","4分","1293公里",153.5,"0","0","0","232.5\/238.5\/244.5","333.5\/345.5"]},
{"content":[72,"金华西","第一天","18:52","19:07","15分","262公里",85.5,"0","0","0","119.5\/122.5\/124.5","148.5\/152.5"]},
{"content":[31,"兰考","第二天","12:29","12:39","10分","1381公里",91.5,"0","0","0","174.5\/181.5\/187.5","282.5\/295.5"]},
{"mxl":16683831947510,"content":[107,"郑州","第二天","14:20","终到站","-","1496公里",170.5,"0","0","0","258.5\/265.5\/272.5","372.5\/386.5"]},
{"mxl":9451012451240,"content":[90,"民权","第二天","12:04","12:07","3分","1345公里",149.5,"0","0","0","230.5\/236.5\/243.5","335.5\/347.5"]}]});"

 

三、源代码

<?php
var_dump(getTrainInfo("t110"));

function getTrainInfo($line)
{
    $curTime = explode (" ", microtime());  
    $curMicroTime = round($curTime[1].($curTime[0]*1000));
    $url = "http://train.qunar.com/qunar/checiInfo.jsp?ex_track=&q=".$line."&format=json&cityname=123456&ver=".$curMicroTime."&callback=XQScript_5";

    $headers = array(
        "User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:14.0) Gecko/20100101 Firefox/14.0.1",
        "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
        "Accept-Language: en-us,en;q=0.5",
        //"Accept-Encoding: gzip, deflate",
        "Referer: http://train.qunar.com/list_num.htm?fromStation=".$line
    );
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); 
    $result = curl_exec($ch);
    curl_close($ch);
    
    return $result;
}
?>

 

四、遗留问题

返回数据不是按顺序排列的。。。。。。
需要再找排列的算法

自学PHP网专注网站建设学习,PHP程序学习,平面设计学习,以及操作系统学习

京ICP备14009008号-1@版权所有www.zixuephp.com

网站声明:本站所有视频,教程都由网友上传,站长收集和分享给大家学习使用,如由牵扯版权问题请联系站长邮箱904561283@qq.com

添加评论