{ "code": 1, "msg": "数据返回成功!", "data": { "address": "广东省 深圳市", "cityCode": "440300", "reportTime": "2022-09-19 13:30:19", "forecasts": [{ "date": "2022-09-19", "dayOfWeek": "1", "dayWeather": "多云", "nightWeather": "多云", "dayTemp": "34℃", "nightTemp": "27℃", "dayWindDirection": "北", "nightWindDirection": "北", "dayWindPower": "≤3级", "nightWindPower": "≤3级" }, { "date": "2022-09-20", "dayOfWeek": "2", "dayWeather": "多云", "nightWeather": "多云", "dayTemp": "32℃", "nightTemp": "24℃", "dayWindDirection": "东", "nightWindDirection": "东", "dayWindPower": "4级", "nightWindPower": "4级" }, { "date": "2022-09-21", "dayOfWeek": "3", "dayWeather": "多云", "nightWeather": "多云", "dayTemp": "30℃", "nightTemp": "25℃", "dayWindDirection": "北", "nightWindDirection": "北", "dayWindPower": "≤3级", "nightWindPower": "≤3级" }, { "date": "2022-09-22", "dayOfWeek": "4", "dayWeather": "晴", "nightWeather": "多云", "dayTemp": "32℃", "nightTemp": "25℃", "dayWindDirection": "北", "nightWindDirection": "北", "dayWindPower": "≤3级", "nightWindPower": "≤3级" }] } }
<?php /** * Created by PhpStorm. * User: FZS * Time: 2022/09/19 14:56 */ class freeApi { private $apiUrl; public function __construct() { $this->apiUrl = 'https://www.mxnzp.com/api/weather/forecast/深圳市?app_id=your&app_secret=your'; } /** * 获取结果 * @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/weather/forecast/深圳市?app_id=your&app_secret=your" ) 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)) }