首页 火车查询 火车查询示例代码 站站查询[PHP]

站站查询示例代码[PHP]

作者: 阅读数:1433 上传时间:2016-03-10

站站查询

<?php

require_once 'curl.func.php';

$appkey = 'your_appkey_here';//你的appkey
$start = '杭州';//utf8
$end = '北京';//utf8
$ishigh = 0;
$url = "https://api.jisuapi.com/train/station2s?appkey=$appkey&start=$start&end=$end&ishigh=$ishigh";
$result = curlOpen($url, ['ssl'=>true]);
$jsonarr = json_decode($result, true);
//exit(var_dump($jsonarr));
if($jsonarr['status'] != 0)
{
    echo $jsonarr['msg'];
    exit();
}

foreach($jsonarr['result'] as $val)
{
    echo $val['trainno'].' '.$val['type'].' '.$val['station'].' '.$val['endstation'].' '.$val['departuretime'].' '.$val['arrivaltime'].'
'; }