GET https://api.8i5.net/yan/ HTTP/1.1
Host: api.8i5.net
{"data":{"content":{"id":null,"content":"抛弃时间的人时间抛弃他。","created_at":"2024-05-09 01:35:07","updated_at":"2024-05-09 01:35:07"}},"status":1,"msg":"Oaklee Api数据获取成功!"}
<?php
$url = "https://api.8i5.net/yan";
// 发起 GET 请求
$response = file_get_contents($url);
// 解析 JSON 响应
$data = json_decode($response, true);
// 提取句子内容
$content = $data['data']['content']['content'];
echo $content;
?>
<div id="quote"></div>
<script>
function fetchQuote() {
fetch('https://api.8i5.net/yan')
.then(response => response.json())
.then(data => {
const quote = data.data.content.content;
document.getElementById('quote').textContent = quote;
})
.catch(error => console.error('Error fetching quote:', error));
}
// 初次加载页面时获取句子
fetchQuote();
</script>