{ "results": [{ "location": { "id": "WX4FBXXFKE4F", "name": "北京", "country": "CN", "path": "北京,北京,我们", "timezone": "Asia/Shanghai", "timezone_offset": "+08:00" }, "daily": [{ "date": "2022-05-06", "text_day": "小雨", "code_day": "13", "text_night": "晴", "code_night": "1", "high": "23", "low": "10", "rainfall": "5.40", "precip": "0.93", "wind_direction": "东北", "wind_direction_degree": "45", "wind_speed": "23.4", "wind_scale": "4", "humidity": "48" }, { "date": "2022-05-07", "text_day": "多云", "code_day": "4", "text_night": "小雨", "code_night": "13", "high": "20", "low": "10", "rainfall": "4.71", "precip": "0.93", "wind_direction": "西南", "wind_direction_degree": "225", "wind_speed": "8.4", "wind_scale": "2", "humidity": "56" }, { "date": "2022-05-08", "text_day": "多云", "code_day": "4", "text_night": "晴", "code_night": "1", "high": "17", "low": "10", "rainfall": "0.00", "precip": "0.00", "wind_direction": "南", "wind_direction_degree": "180", "wind_speed": "3.0", "wind_scale": "1", "humidity": "91" }], "last_update": "2022-05-06T08:00:00+08:00" }] }
<?php /** * Created by PhpStorm. * User: FZS * Time: 2022/04/08 11:38 */ class freeApi { private $apiUrl; public function __construct() { $this->apiUrl = 'https://api.seniverse.com/v3/weather/daily.json?key=youkey&location=beijing&language=zh-Hans&unit=c&start=0&days=5'; } /** * 获取结果 * @return array */ public function getResult() { return file_get_contents($this->apiUrl); } }
package main import ( "fmt" "io/ioutil" "log" "net/http" ) const ( APIURL = "https://api.seniverse.com/v3/weather/daily.json?key=youkey&location=beijing&language=zh-Hans&unit=c&start=0&days=5" ) 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)) }