{ "code": "10000", "charge": false, "msg": "查询成功", "result": { "status": "0", "msg": "ok", "result": [{ "transitno": "86路", "startstation": "西溪竞舟苑", "endstation": "景芳小区", "starttime": "05:45", "endtime": "21:45", "price": "2", "maxprice": "2.00", "list": [{ "sequenceno": "1", "station": "西溪竞舟苑", "lat": "30.28806", "lng": "120.06484" }, { "sequenceno": "22", "station": "和平广场", "lat": "30.29524", "lng": "120.18258" }, { "sequenceno": "25", "station": "濮家新村", "lat": "30.29059", "lng": "120.20558" }, { "sequenceno": "29", "station": "景芳小区", "lat": "30.27631", "lng": "120.21277" } ] }] } }
<?php /** * Created by PhpStorm. * User: FZS * Time: 2021/01/01 21:26 */ class freeApi { private $apiUrl; public function __construct() { $this->apiUrl = 'https://way.jd.com/jisuapi/transitLine?city=杭州&cityid=382&transitno=86&appkey=您申请的APPKEY'; } /** * 获取结果 * @return array */ public function getResult() { return file_get_contents($this->apiUrl); } }
package main import ( "fmt" "io/ioutil" "log" "net/http" ) const ( APIURL = "https://way.jd.com/jisuapi/transitLine?city=杭州&cityid=382&transitno=86&appkey=您申请的APPKEY" ) func main() { queryUrl := fmt.Sprintf("%s",APIURL) resp, err := http.Get(queryUrl) if err != nil { log.Println(err) return } defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println(err) return } fmt.Println(string(body)) }