接口地址:https://www.mxnzp.com/api/holiday/single/{date} |
---|
返回格式:json |
请求方式:get/post |
请求示例:https://www.mxnzp.com/api/holiday/single/20220529?ignoreHoliday=false&app_id=youid&app_secret=yousecret |
名称 | 类型 | 必填 | 说明 |
---|---|---|---|
app_id | string | 必填 | app_id 扫码关注公众号 |
app_secret | string | 必填 | app_secret 扫码关注公众号 |
date | string | 必填 | 日期 格式 yyyyMMdd |
ignoreHoliday | bool | 选填 | 是否忽略节假日,仅仅获取万年历,默认值false |
名称 | 类型 | 说明 |
---|---|---|
date | string | 当前日期 |
weekDay | int | 当前周第几天 1-周一 2-周二 ... 7-周日 |
yearTips | string | 天干地支纪年法描述 例如:戊戌 |
type | int | 类型 0 工作日 1 假日 2 节假日 如果ignoreHoliday参数为true,这个字段不返回 |
typeDes | string | 类型描述 比如 国庆 |
chineseZodiac | string | 属相 例如:狗 |
solarTerms | string | 节气描述 例如:小雪 |
lunarCalendar | string | 农历日期 |
suit | string | 宜事项 |
dayOfYear | int | 这一年的第几天 |
weekOfYear | int | 这一年的第几周 |
constellation | string | 星座 |
indexWorkDayOfMonth | int | 如果当前是工作日 则返回是当前月的第几个工作日,否则返回0 如果ignoreHoliday参数为true,这个字段不返回 |
{
"code": 1,
"msg": "数据返回成功!",
"data": {
"date": "2022-05-29",
"weekDay": 7,
"yearTips": "壬寅",
"type": 1,
"typeDes": "休息日",
"chineseZodiac": "虎",
"solarTerms": "小满后",
"avoid": "嫁娶.安床.探病.作灶",
"lunarCalendar": "四月廿九",
"suit": "开市.交易.立券.挂匾.开光.出行.拆卸.进人口.入宅.移柩.动土.安门.上梁.栽种.破土.修坟.安葬",
"dayOfYear": 149,
"weekOfYear": 21,
"constellation": "双子座",
"indexWorkDayOfMonth": 0
}
}
错误码 | 说明 |
---|---|
0 | app_id或者app_secret不合法 |
<?php
/**
* Created by PhpStorm.
* User: FZS
* Time: 2022/05/01 11:38
*/
class freeApi
{
private $apiUrl;
public function __construct()
{
$this->apiUrl = 'https://www.mxnzp.com/api/holiday/single/20220529?ignoreHoliday=false&app_id=youid&app_secret=yousecret';
}
/**
* 获取结果
* @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/holiday/single/20220529?ignoreHoliday=false&app_id=youid&app_secret=yousecret"
)
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))
}