外链 API
把这个接口交给对方网站,即可读取品牌名称和链接。公开只读,无需 Key,支持跨域。
GET https://links-demo-1106.43.199.41.56.sslip.io/api/links返回示例
{
"success": true,
"total": 3,
"count": 3,
"offset": 0,
"links": [
{
"name": "99rp",
"url": "https://99rp.world"
},
{
"name": "99RS",
"url": "https://99rsapkunduh.com"
},
{
"name": "YY123",
"url": "https://unduhyy123apk.com"
}
]
}可选参数
| 参数 | 作用 | 示例 |
|---|
| limit | 返回数量,1—50 | ?limit=3 |
| offset | 从第几条开始,0 起算 | ?limit=2&offset=1 |
| format | json 或 html | ?format=html |
当前列表有 3 条示例。缓存 60 秒,重复读取不会随机改变顺序。
怎么接到网站
对方后端请求接口后,将 name 作为链接文字、url 作为链接地址,输出到网页正文。前端也可以直接 fetch 调用。
<div id="external-links"></div>
<script>
fetch("https://links-demo-1106.43.199.41.56.sslip.io/api/links?limit=3")
.then(response => {
if (!response.ok) throw new Error("链接接口暂时不可用");
return response.json();
})
.then(data => {
const container = document.getElementById("external-links");
for (const link of data.links) {
const a = document.createElement("a");
a.href = link.url;
a.textContent = link.name;
a.target = "_blank";
a.rel = "noopener";
a.style.marginRight = "16px";
container.appendChild(a);
}
})
.catch(console.error);
</script>API 本身不会替对方网站加链接。以 SEO 为主要目的时,建议后端读取后直接输出 HTML。
查看之前的 HTML 嵌入演示