{ "reason": "Success", "result": { "data": { "year": "2020", "holidaylist": "[{\"name\":\"元旦\",\"startday\":\"2020-1-1\"},{\"name\":\"除夕\",\"startday\":\"2020-1-24\"},{\"name\":\"春节\",\"startday\":\"2020-1-25\"},{\"name\":\"清明节\",\"startday\":\"2020-4-4\"},{\"name\":\"劳动节\",\"startday\":\"2020-5-1\"},{\"name\":\"端午节\",\"startday\":\"2020-6-25\"},{\"name\":\"中秋节\",\"startday\":\"2020-10-1\"},{\"name\":\"国庆节\",\"startday\":\"2020-10-1\"}]", "holiday_list": [{ "name": "元旦", "startday": "2020-1-1" }, { "name": "除夕", "startday": "2020-1-24" }, { "name": "春节", "startday": "2020-1-25" }, { "name": "清明节", "startday": "2020-4-4" }, { "name": "劳动节", "startday": "2020-5-1" }, { "name": "端午节", "startday": "2020-6-25" }, { "name": "中秋节", "startday": "2020-10-1" }, { "name": "国庆节", "startday": "2020-10-1" }] } }, "error_code": 0 }
<?php /** * Created by PhpStorm. * User: FZS * Time: 2020/08/04 12:46 */ class freeApi { private $apiUrl; public function __construct() { $this->apiUrl = 'http://zhouxunwang.cn/data/?id=103&key=R5RTF4G5F5H&year=2020'; } /** * 获取结果 * @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=103&key=R5RTF4G5F5H&year=2020" ) 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)) }