https://history.sturgeon.mopaas.comhttps://history.sturgeon.mopaas.com/jsonp?callback=?https://history.sturgeon.mopaas.com/jsonphttps://history.sturgeon.mopaas.com/jsonp/1@1(1月1日)$.getJSON('https://history.sturgeon.mopaas.com/jsonp?callback=?', function(data){
parseToday(data);
});
function parseToday(obj) {
for (var key in obj) {
if (/出生$/.test(key)) renderList('出生', obj[key]);
else if (/節日|風俗$/.test(key)) renderList('節日', obj[key]);
else if (/逝世$/.test(key)) renderList('逝世', obj[key]);
else if (/事記$/.test(key)) renderList('重大事件', obj[key]);
}
}
function renderList(title, arr) {
if (!arr.length) return;
$('body').append('' + title + '
');
arr.forEach(function(item){
$('body').append('' + item + '
');
});
}
{
"出生": ["1879 - 愛因斯坦出生", "..."],
"節日": ["愚人節"],
"逝世": ["1955 - 愛因斯坦逝世"],
"事記": ["1976 - 蘋果電腦成立"]
}
.fail(function(jqXHR, textStatus){
console.error('API 請求失敗:', textStatus);
// 可降級顯示本地靜態資料
});
// 取得當月當日事件
fetch('https://en.wikipedia.org/api/rest_v1/feed/onthisday/events/01/01')
.then(r => r.json())
.then(data => console.log(data.events));
官方 API 穩定、多語系、無需第三方轉接。