历史上的今天
如初助手API

接口地址: https://www.58.linkpc.net/api/today

返回格式: 请看返回示例

请求方式: GET

请求示例: https://www.58.linkpc.net/api/today

请求参数说明:

名称 必填 类型 说明

返回参数说明:

名称 类型 说明

返回示例:

{"code":1000,"data":{"list":["英国哲学家休谟出生","中国著名工程师詹天佑出生","语言哲学的奠基人物路德维希·维特根斯坦出生","德国纳粹党副领袖鲁道夫·沃尔特·理查德·赫斯出生","中国清华大学建校","现代建筑大师贝聿铭出生","毛泽东之弟毛泽覃逝世","南京大屠杀首恶谷寿夫被枪决","日内瓦会议召开","香港企业家何东逝世","中国与坦桑尼亚共和国建交","中华民国财政部长、宋美龄之兄宋子文逝世","前苏联切尔诺贝利核电站发生核泄漏","香港语言学家刘殿爵逝世"]}}

错误码格式说明:

名称 类型 说明

代码示例:

<?php
header('Content-type: application/json; charset=utf-8');
date_default_timezone_set('PRC');
$url = 'https://58.linkpc.net/api/today';
$type = isset($_GET['type']) ? $_GET['type'] : '';
if ($type == 'json' || $type == 'JSON') {
$result = file_get_contents($url . '?type=json');
echo $result;
} else {
// 使用cURL获取URL内容
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);

// 检查内容类型并输出相应内容
$contentType = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
curl_close($ch);

if (strpos($contentType, 'image') !== false) {
// 输出图片
header('Content-Type: ' . $contentType);
echo $response;
} elseif (strpos($contentType, 'text') !== false) {
// 输出文字
header('Content-Type: ' . $contentType);
echo $response;
} elseif (strpos($contentType, 'application/json') !== false) {
// 输出JSON
header('Content-Type: application/json');
echo $response;
} else {
// 输出网页返回内容
header('Content-Type: text/html');
echo $response;
}
}
?>