Bus/transfer
Zhangchao2 (讨论 | 贡献) (→返回结果) |
|||
(未显示1个用户的1个中间版本) | |||
第58行: | 第58行: | ||
| 查询类型(0:最快捷,1:最经济,2:最少换乘,3:最少步行,4:最舒适) | | 查询类型(0:最快捷,1:最经济,2:最少换乘,3:最少步行,4:最舒适) | ||
|} | |} | ||
+ | |||
== '''返回结果''' == | == '''返回结果''' == | ||
+ | |||
+ | === '''XML示例''' === | ||
+ | <pre> | ||
+ | <?xml version="1.0" encoding="UTF-8" ?> | ||
+ | <geoResult> | ||
+ | <status>1</status> | ||
+ | <count>10</count> | ||
+ | <type>0</type> | ||
+ | <city>0010</city> | ||
+ | <begin_id>P010A00CHR9</begin_id> | ||
+ | <end_id>P010A00CWWJ</end_id> | ||
+ | <end_coordinate>116.2739,39.99957</end_coordinate> | ||
+ | <start_coordinate>116.22074,39.90652</start_coordinate> | ||
+ | <extension_info>0</extension_info> | ||
+ | <transfers> | ||
+ | <transfer> | ||
+ | <result_id>1</result_id> | ||
+ | <distance>18534米</distance> | ||
+ | <expense>0</expense> | ||
+ | <before_len>160米</before_len> | ||
+ | <last_len>820</last_len> | ||
+ | <nav_count>2</nav_count> | ||
+ | <drive_coordinates>116.21946,39.90754;116.21489,39.90751;...</drive_coordinates> | ||
+ | <lines> | ||
+ | <line> | ||
+ | <seg_id>1</seg_id> | ||
+ | <name>598路(西道口--八大处)</name> | ||
+ | <distance>4470米</distance> | ||
+ | <last_len>160米</last_len> | ||
+ | <stop_num>7</stop_num> | ||
+ | <stations> | ||
+ | <station> | ||
+ | <name>京原东</name> | ||
+ | <longitude>116.21946</longitude> | ||
+ | <latitude>116.21946</latitude> | ||
+ | <district /> | ||
+ | <station_info /> | ||
+ | <telephone /> | ||
+ | <address /> | ||
+ | </station> | ||
+ | ... | ||
+ | </stations> | ||
+ | </line> | ||
+ | ... | ||
+ | </lines> | ||
+ | </transfer> | ||
+ | ... | ||
+ | </transfers> | ||
+ | </geoResult> | ||
+ | |||
+ | </pre> | ||
=== '''JSON示例''' === | === '''JSON示例''' === | ||
<pre> | <pre> | ||
− | {" | + | { |
+ | "status":1, | ||
+ | "count":"10", | ||
+ | "type":0, | ||
+ | "city":"0010", | ||
+ | "begin_id":"P010A00CHR9", | ||
+ | "end_id":"P010A00CWWJ", | ||
+ | "end_coordinate":"116.2739,39.99957", | ||
+ | "start_coordinate":"116.22074,39.90652", | ||
+ | "extension_info":"0", | ||
+ | "transfers": | ||
+ | [ | ||
+ | { | ||
+ | "result_id":"1", | ||
+ | "distance":"18534\u7c73", | ||
+ | "expense":"0", | ||
+ | "before_len":"160米", | ||
+ | "last_len":"820" , | ||
+ | "nav_count":"2" , | ||
+ | "drive_coordinates":"116.21946,39.90754;116.21489,39.90751;...", | ||
+ | "lines": | ||
+ | [ | ||
+ | { | ||
+ | "seg_id":"1", | ||
+ | "name":"598\u8def(\u897f\u9053\u53e3--\u516b\u5927\u5904)", | ||
+ | "distance":"4470\u7c73", | ||
+ | "last_len":"160\u7c73", | ||
+ | "stop_num":"7", | ||
+ | "stations": | ||
+ | [ | ||
+ | { | ||
+ | "name":"\u4eac\u539f\u4e1c", | ||
+ | "longitude":116.21946, | ||
+ | "latitude":116.21946, | ||
+ | "district":"", | ||
+ | "station_info":"", | ||
+ | "telephone":"", | ||
+ | "address":"" | ||
+ | }, | ||
+ | ... | ||
+ | ] | ||
+ | }, | ||
+ | ... | ||
+ | ] | ||
+ | }, | ||
+ | ... | ||
+ | ] | ||
+ | } | ||
</pre> | </pre> | ||
+ | |||
+ | === '''字段说明 ''' === | ||
+ | :status:标识结果,1表示查询正常; | ||
+ | :count:结果条数 | ||
+ | :type:查询类型(0:最快捷,1:最经济,2:最少换乘,3:最少步行,4:最舒适) | ||
+ | :city:城市代码 | ||
+ | :begin_id:起点id | ||
+ | :end_id:终点id | ||
+ | :end_coordinate:终点坐标 | ||
+ | :start_coordinate:起点坐标 | ||
+ | :extension_info:当前返回状态补充信息 | ||
+ | :transfers:换乘方案列表 | ||
+ | ::result_id:结果类型(1为有结果,0为无结果) | ||
+ | ::nav_count:导航段数 | ||
+ | ::distance:总距离 | ||
+ | ::before_len:之前需步行的距离 | ||
+ | ::last_len:最后还需步行的距离 | ||
+ | ::expense:花费(未使用) | ||
+ | ::drive_coordinates:路线的坐标串 | ||
+ | ::station_info:上下车站的信息串 | ||
+ | ::lines:本方案中的导航段 | ||
+ | ::::seg_id:导航段在本方案中的id | ||
+ | ::::name:导航段名称 | ||
+ | ::::distance:本导航段距离 | ||
+ | ::::last_len:本导航段结束后需要步行的距离 | ||
+ | ::::stop_num:本导航段共有几站 | ||
+ | ::::stations:本段从上车站到下车站的所有站点 | ||
+ | ::::::name:站名 | ||
+ | ::::::longitude:站点经度 | ||
+ | ::::::latitude:站点纬度 | ||
+ | ::::::district:区 | ||
+ | ::::::station_info:站点详情 | ||
+ | ::::::telephone:电话 | ||
+ | ::::::address:地址 | ||
== '''其它''' == | == '''其它''' == |
2012年9月24日 (一) 11:51的最后版本
目录 |
bus/transfer
根据起始ID或坐标等进行搜索,返回公交换乘路线信息
URL
http://api.t.sina.com.cn/location/bus/transfer.(json%7Cxml)
支持格式
XML/JSON
HTTP请求方式
GET
是否需要登录
true
请求数限制
true
请求参数
参数 | 必选 | 类型及范围 | 说明 |
---|---|---|---|
source | true | string | 申请应用时分配的AppKey,调用接口时候代表应用的唯一身份 |
注意:以下两个参数至少选填一个 | |||
begin_id | false | string | 起点的id(会覆盖begin_coordinate) |
begin_coordinate | false | string | 起点的坐标(逗号分隔,若有id以id为准) |
注意:以下两个参数至少选填一个 | |||
end_id | false | string | 终点的id(会覆盖end_coordinate) |
end_coordinate | false | string | 终点的坐标(逗号分隔,若有id以id为准) |
注意:以下参数选填 | |||
type | false | int | 查询类型(0:最快捷,1:最经济,2:最少换乘,3:最少步行,4:最舒适) |
返回结果
XML示例
<?xml version="1.0" encoding="UTF-8" ?> <geoResult> <status>1</status> <count>10</count> <type>0</type> <city>0010</city> <begin_id>P010A00CHR9</begin_id> <end_id>P010A00CWWJ</end_id> <end_coordinate>116.2739,39.99957</end_coordinate> <start_coordinate>116.22074,39.90652</start_coordinate> <extension_info>0</extension_info> <transfers> <transfer> <result_id>1</result_id> <distance>18534米</distance> <expense>0</expense> <before_len>160米</before_len> <last_len>820</last_len> <nav_count>2</nav_count> <drive_coordinates>116.21946,39.90754;116.21489,39.90751;...</drive_coordinates> <lines> <line> <seg_id>1</seg_id> <name>598路(西道口--八大处)</name> <distance>4470米</distance> <last_len>160米</last_len> <stop_num>7</stop_num> <stations> <station> <name>京原东</name> <longitude>116.21946</longitude> <latitude>116.21946</latitude> <district /> <station_info /> <telephone /> <address /> </station> ... </stations> </line> ... </lines> </transfer> ... </transfers> </geoResult>
JSON示例
{ "status":1, "count":"10", "type":0, "city":"0010", "begin_id":"P010A00CHR9", "end_id":"P010A00CWWJ", "end_coordinate":"116.2739,39.99957", "start_coordinate":"116.22074,39.90652", "extension_info":"0", "transfers": [ { "result_id":"1", "distance":"18534\u7c73", "expense":"0", "before_len":"160米", "last_len":"820" , "nav_count":"2" , "drive_coordinates":"116.21946,39.90754;116.21489,39.90751;...", "lines": [ { "seg_id":"1", "name":"598\u8def(\u897f\u9053\u53e3--\u516b\u5927\u5904)", "distance":"4470\u7c73", "last_len":"160\u7c73", "stop_num":"7", "stations": [ { "name":"\u4eac\u539f\u4e1c", "longitude":116.21946, "latitude":116.21946, "district":"", "station_info":"", "telephone":"", "address":"" }, ... ] }, ... ] }, ... ] }
字段说明
- status:标识结果,1表示查询正常;
- count:结果条数
- type:查询类型(0:最快捷,1:最经济,2:最少换乘,3:最少步行,4:最舒适)
- city:城市代码
- begin_id:起点id
- end_id:终点id
- end_coordinate:终点坐标
- start_coordinate:起点坐标
- extension_info:当前返回状态补充信息
- transfers:换乘方案列表
- result_id:结果类型(1为有结果,0为无结果)
- nav_count:导航段数
- distance:总距离
- before_len:之前需步行的距离
- last_len:最后还需步行的距离
- expense:花费(未使用)
- drive_coordinates:路线的坐标串
- station_info:上下车站的信息串
- lines:本方案中的导航段
- seg_id:导航段在本方案中的id
- name:导航段名称
- distance:本导航段距离
- last_len:本导航段结束后需要步行的距离
- stop_num:本导航段共有几站
- stations:本段从上车站到下车站的所有站点
- name:站名
- longitude:站点经度
- latitude:站点纬度
- district:区
- station_info:站点详情
- telephone:电话
- address:地址
其它
PHP示例
需要开启PHP的cURL扩展
<?php //改为你的微博账号,用户名和密码之间用:隔开 $userPwd = 'user@sina.com:pwd'; //改为你微博应用的appkey $appkey = '0123456789'; $url = "http://api.t.sina.com.cn/location/bus/transfer.xml?begin_id=P010A00CHR9&end_id=P010A00CWWJ&source=$appkey"; $rst = curlSample($url,$userPwd); echo $rst; function curlSample($url,$userPwd,$postFields = '',$header = ''){ $ch = curl_init() or die (curl_error()) ; curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); curl_setopt($ch,CURLOPT_TIMEOUT,30); if(!empty($userPwd)){ curl_setopt($ch,CURLOPT_USERPWD,$userPwd); } if(!empty($postFields)){ curl_setopt($ch,CURLOPT_POST,true); curl_setopt($ch,CURLOPT_POSTFIELDS,$postFields); } if(!empty($header)){ curl_setopt($ch, CURLOPT_HTTPHEADER,$header); } $result = curl_exec($ch) or die (curl_error($ch)); curl_close($ch); return $result; } ?>
文档更新时间: 2012-09-24