{ "error_code": 0, "result": [{ "province": "安徽省", "city": "池州市", "area": "青阳县", "post_code": "242800", "area_code": "0566" }, { "province": "安徽省", "city": "池州市", "area": "东至县", "post_code": "247200", "area_code": "0566" }, { "province": "安徽省", "city": "池州市", "area": "贵池区", "post_code": "247100", "area_code": "0566" }, { "province": "安徽省", "city": "池州市", "area": "石台县", "post_code": "245100", "area_code": "0566" }, { "province": "安徽省", "city": "池州市", "area": "池州市", "post_code": "247100", "area_code": "0566" }] }
<?php /** * Created by PhpStorm. * User: FZS * Time: 2020/07/04 22:26 */ class freeApi { private $apiUrl; public function __construct() { $this->apiUrl = 'http://zhouxunwang.cn/data/?id=110&key=我的KEY&name=城市名称'; } /** * 获取结果 * @return array */ public function getResult() { return file_get_contents($this->apiUrl); } }
package main import ( "fmt" "io/ioutil" "log" "net/http" ) const ( APIURL = "http://zhouxunwang.cn/data/?id=110&key=我的KEY&name=城市名称" ) 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)) }