天气预报查询
Kate·Api 官方文档
查询未来七天的天气预报信息
基本说明:
接口地址:https://api.66mz8.com/api/weather.php
返回格式:json
请求方式:get/post
请求示例:https://api.66mz8.com/api/weather.php?location=北京
请求参数说明:
名称 类型 必填 说明
location string 必填 需要查询的位置名称
返回参数说明:
名称 类型 说明
- - -
JSON返回示例:
{
	"code": 200,
	"citynm": "北京",
	"cityno": "beijing",
	"data": [{
			"days": "2020-05-01",
			"week": "星期五",
			"temperature": "35℃\/21℃",
			"weather": "晴",
			"weather_icon": "http:\/\/api.k780.com\/upload\/weather\/d\/0.gif",
			"wind": "南风"
		},
		{
			"days": "2020-05-02",
			"week": "星期六",
			"temperature": "34℃\/19℃",
			"weather": "晴",
			"weather_icon": "http:\/\/api.k780.com\/upload\/weather\/d\/0.gif",
			"wind": "东南风转东风"
		},
		{
			"days": "2020-05-03",
			"week": "星期日",
			"temperature": "28℃\/15℃",
			"weather": "多云转中雨",
			"weather_icon": "http:\/\/api.k780.com\/upload\/weather\/d\/1.gif",
			"wind": "东风"
		},
		{
			"days": "2020-05-04",
			"week": "星期一",
			"temperature": "26℃\/12℃",
			"weather": "多云转晴",
			"weather_icon": "http:\/\/api.k780.com\/upload\/weather\/d\/1.gif",
			"wind": "西南风"
		},
		{
			"days": "2020-05-05",
			"week": "星期二",
			"temperature": "25℃\/13℃",
			"weather": "多云",
			"weather_icon": "http:\/\/api.k780.com\/upload\/weather\/d\/1.gif",
			"wind": "西南风转南风"
		},
		{
			"days": "2020-05-06",
			"week": "星期三",
			"temperature": "25℃\/13℃",
			"weather": "晴转多云",
			"weather_icon": "http:\/\/api.k780.com\/upload\/weather\/d\/0.gif",
			"wind": "东南风"
		},
		{
			"days": "2020-05-07",
			"week": "星期四",
			"temperature": "25℃\/15℃",
			"weather": "多云转阴",
			"weather_icon": "http:\/\/api.k780.com\/upload\/weather\/d\/1.gif",
			"wind": "东北风转北风"
		}
	]
}
服务级错误码参照
错误码 说明
202 查询地址信息有误
完整教学代码示例
<?php
/**
 * Created by PhpStorm.
 * User: FZS
 * Time: 2020/04/04 23:26
 */
class freeApi
{
    private $apiUrl;

    public function __construct()
    {
        $this->apiUrl = 'https://api.66mz8.com/api/weather.php?location=北京';
    }

    /**
     * 获取结果
     * @return array
     */
    public function getResult()
    {
        return file_get_contents($this->apiUrl);
    }
}
package main

import (
	"fmt"
	"io/ioutil"
	"log"
	"net/http"
)

const (
	APIURL   = "https://api.66mz8.com/api/weather.php?location=北京"
)

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))
}