我尝试使用 Discourse API 为 Discord 机器人开发功能。我希望通过机器人传递搜索查询,并利用 Discourse API 返回结果到 Discord。
问题是 API 无法正常工作,它只返回了一段 HTML 代码。以下是我的 CURL 请求:
curl --location --request GET 'https://forum.andronix.app/search/query?term=Modded%20OS' \
--header 'Api-Key: xxxx2901589946b34f0e81bfc39xxx633deef202b6f004af878fa62xxxxxxxxx' \
--header 'Api-Username: xxxx'
[API 密钥和用户名是正确的,因为它们在其他操作中有效]。
这是我收到的响应:
<!DOCTYPE html>
<html lang="en-US" class="desktop-view not-mobile-device text-size-normal">
<head>
<meta charset="utf-8">
<title>Andronix Community</title>
<meta name="description" content="A place for everything Linux and Andronix">
<meta name="discourse_theme_ids" content="3">
<meta name="discourse_current_homepage" content="categories">
<meta name="generator" content="Discourse 2.5.0.beta3 - https://github.com/discourse/discourse version 5285cbee62ad7b0cee5b3bf0b6449174fb4f4491">
<link rel="icon" type="image/png" href="https://forum.andronix.app/uploads/default/optimized/1X/3f26e0ac92e114364358d8cfce8c5734ddacf980_2_32x32.png">
<link rel="apple-touch-icon" type="image/png" href="https://forum.andronix.app/uploads/default/optimized/1X/3f26e0ac92e114364358d8cfce8c5734ddacf980_2_180x180.png">
<meta name="theme-color" content="#36393e">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, user-scalable=yes, viewport-fit=cover">
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "WebSite",
"url": "https://forum.andronix.app",
"potentialAction": {
"@type": "SearchAction",
"target": "https://forum.andronix.app/search?q={search_term_string}",
"query-input": "required name=search_term_string"
}
}
</script>
<link rel="search" type="application/opensearchdescription+xml" href="https://forum.andronix.app/opensearch.xml" title="Andronix Community Search">
<meta name="csrf-param" content="authenticity_token" />
<meta name="csrf-token" content="3uVup/2b5g9JbWa3bJN0KA8RxeGi64VUXPBO6I58jsvja3QBTtPDeJtvyjlqnL4bSVQ77VuGmc665ukh7ir6aQ==" />
<meta name="fragment" content="!">
<link rel="preload" href="/assets/browser-update-331af91e0f999788d03c2128d366d5d0df480718b9e80914bfb0505cbb97af13.js" as="script">
<script src="/assets/browser-update-331af91e0f999788d03c2128d366d5d0df480718b9e80914bfb0505cbb97af13.js"></script>
</body>
</html>
我已缩短响应内容以避免看起来像垃圾信息
如果有人能指出我哪里出错了,我将不胜感激。谢谢!