{ "code": 1, "msg": "数据返回成功!", "data": [{ "code": "110000", "name": "北京市", "pchilds": [{ "code": "110100", "name": "市辖区", "cchilds": [{ "code": "110101", "name": "东城区" }, { "code": "110102", "name": "西城区" }, { "code": "110105", "name": "朝阳区" }, { "code": "110106", "name": "丰台区" }, { "code": "110107", "name": "石景山区" }, { "code": "110108", "name": "海淀区" }, { "code": "110109", "name": "门头沟区" }, { "code": "110111", "name": "房山区" }, { "code": "110112", "name": "通州区" }, { "code": "110113", "name": "顺义区" }, { "code": "110114", "name": "昌平区" }, { "code": "110115", "name": "大兴区" }, { "code": "110116", "name": "怀柔区" }, { "code": "110117", "name": "平谷区" }, { "code": "110118", "name": "密云区" }, { "code": "110119", "name": "延庆区" }] }] }] }
<?php /** * Created by PhpStorm. * User: FZS * Time: 2022/08/04 14:56 */ class freeApi { private $apiUrl; public function __construct() { $this->apiUrl = 'https://www.mxnzp.com/api/address/list?app_id=&app_secret='; } /** * 获取结果 * @return array */ public function getResult() { return file_get_contents($this->apiUrl); } }
package main import ( "fmt" "io/ioutil" "log" "net/http" ) const ( APIURL = "https://www.mxnzp.com/api/address/list?app_id=&app_secret=" ) 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)) }