Skip to content

请教下怎么在html文件中调用最新的几条评论 #887

Answered by qwqcode
koobai asked this question in Q&A
Discussion options

You must be logged in to vote

可以请求这个接口:{你的Artalk地址}/api/v2/stats/latest_comments?site_name=站点名&limit=5 获取最新的 5 条评论

参考以下案例:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Latest Comments</title>
</head>
<body>
    <h1>Latest Comments</h1>
    <ul id="commentsList"></ul>

    <script>
        // 构造请求的URL
        const apiUrl = "{你的Artalk地址}/api/v2/stats/latest_comments?site_name=站点名&limit=5";

        // 发起GET请求
        fetch(apiUrl)
            .then(response => {
                if (!response.ok) {
                    throw new Error('Network response was not ok');
                }
                return response.j…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by qwqcode
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
enhancement New feature or request
2 participants
Converted from issue

This discussion was converted from issue #742 on May 26, 2024 10:08.