首页 公交地铁查询 公交地铁查询示例代码 线路查询[PHP]

线路查询示例代码[PHP]

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

线路查询

<?php

require_once 'curl.func.php';

$appkey = 'your appkey here';//你的appkey
$cityid = 382;//杭州
$transitno = '86';//utf8
$url = "https://api.jisuapi.com/transit/line?appkey=$appkey&cityid=$cityid&transitno=$transitno";
$result = curlOpen($url, ['ssl'=>true]);
$jsonarr = json_decode($result, true);
//exit(var_dump($jsonarr));

if($jsonarr['status'] != 0)
{
    echo $jsonarr['msg'];
    exit();
}

$result = $jsonarr['result'];
echo $result['transitno'].' '.$result['startstation'].' '.$result['endstation'].' '.$result['starttime'].' '.$result['endtime'].' '.$result['price'].' '.$result['maxprice'].' '.'
'; foreach($result['list'] as $val) { foreach($val as $v) { echo $v['sequenceno'].' '.$v['station'].' '.$v['lat'].' '.$v['lng'].'
'; } }