接口地址:https://v2.alapi.cn/api/eventHitory |
---|
返回格式:json |
请求方式:get/post |
请求示例:https://v2.alapi.cn/api/eventHitory?token=token |
名称 | 类型 | 必填 | 说明 |
---|---|---|---|
token | string | 必填 | 请求token 扫码关注公众号 |
monthday | int | 选填 | 月份和日期,如 1014,不填默认获取今天的事件 |
名称 | 类型 | 说明 |
---|---|---|
title | string | 标题 |
desc | string | 描述 |
type | string | 类型 |
{
"code": 200,
"msg": "success",
"data": [{
"year": 1633,
"monthday": "1014",
"title": "英格兰国王詹姆斯二世出生",
"desc": "詹姆斯二世,1633年10月14日出生于英国伦敦圣詹姆斯宫,1701年9月16日逝世。从1685年到1688年是英格兰、苏格兰和爱尔兰的国王。",
"type": "birth"
}],
"Author": {
"name": "Alone88",
"desc": "由Alone88提供的免费API 服务,官方文档:www.alapi.cn"
}
}
错误码 | 说明 |
---|---|
500 | 处理异常 |
<?php
/**
* Created by PhpStorm.
* User: FZS
* Time: 2020/02/01 00:16
*/
class freeApi
{
private $apiUrl;
public function __construct()
{
$this->apiUrl = 'https://v1.alapi.cn/api/eventHitory';
}
/**
* 获取结果
* @return array
*/
public function getResult()
{
return file_get_contents($this->apiUrl);
}
}
package main
import (
"fmt"
"io/ioutil"
"log"
"net/http"
)
const (
APIURL = "https://v1.alapi.cn/api/eventHitory"
)
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))
}