接入教程
1. 访问LectServe官网查看API文档
2. 注册获取API密钥(如需)
3. 使用日期参数调用API端点
4. 解析返回的JSON格式礼拜日历数据
5. 将数据集成到您的应用或网站中
使用Python查询指定日期的礼拜日历
import requests
url = 'https://api.lectserve.com/v1/readings'
params = {
'date': '2023-12-25',
'calendar': 'lectionary-a',
'language': 'zh'
}
headers = {
'Authorization': 'Bearer YOUR_API_KEY',
'Accept': 'application/json'
}
response = requests.get(url, params=params, headers=headers)
if response.status_code == 200:
data = response.json()
print(f"经文: {data.get('readings', [])}")
else:
print(f"请求失败: {response.status_code}")
print(response.text)
使用PHP获取当前礼拜周期的经文安排
<?php
$url = 'https://api.lectserve.com/v1/readings/today';
$options = [
'http' => [
'method' => 'GET',
'header' => "Authorization: Bearer YOUR_API_KEY\r\n" .
"Accept: application/json\r\n"
]
];
$context = stream_context_create($options);
$response = file_get_contents($url, false, $context);
if ($response !== false) {
$data = json_decode($response, true);
echo "日期: " . $data['date'] . "\n";
echo "经文: " . implode(', ', $data['readings']) . "\n";
} else {
echo "请求失败\n";
}
?>
使用JavaScript在网页中显示今日经文
async function fetchTodaysReadings() {
const url = 'https://api.lectserve.com/v1/readings/today';
const options = {
method: 'GET',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Accept': 'application/json'
}
};
try {
const response = await fetch(url, options);
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const data = await response.json();
document.getElementById('date').textContent = data.date;
document.getElementById('readings').innerHTML =
data.readings.map(r => `<li>${r}</li>`).join('');
} catch (error) {
console.error('获取数据失败:', error);
document.getElementById('readings').textContent = '加载失败,请稍后重试。';
}
}
// 页面加载后调用
window.addEventListener('DOMContentLoaded', fetchTodaysReadings);
常见问题
LectServe API是免费的吗?
是的,LectServe是一个完全免费的API服务,为教会和信徒提供新教礼拜日历数据。无需付费订阅,只需注册获取API密钥即可使用。
API返回的数据包含哪些内容?
API返回指定日期的完整礼拜安排,包括经文阅读(旧约、诗篇、新约书信、福音书)、节日名称、礼拜周期(如将临期、复活期)以及可选的自定义注释。
支持哪些日期格式和查询参数?
API支持ISO 8601标准日期格式(YYYY-MM-DD),并可查询特定年份的完整礼拜日历。主要参数包括:date(日期)、calendar(历法类型,如lectionary-a)、language(返回语言,支持zh、en等)。
Aitishiku.com