应该怎么拿这个 api 做接口来使用尼,

2020-12-16 23:07:54 +08:00
 BaiLinfeng

我想拿这个现成的 api 来做接口来自己给小程序使用,https://github.com/CaptEmulation/clash-of-clans-api,不知道该怎么操作。

1956 次点击
所在节点    程序员
6 条回复
YuxiangLuo
2020-12-16 23:19:57 +08:00
https://github.com/CaptEmulation/clash-of-clans-api

Nodejs 起一个 http 服务,收到小程序的请求,调用这个 API,返回给小程序,这不是很简单嘛

const express = require("express");
const clashApi = require("clash-of-clans-api");

const app = express();
let client = clashApi({
token: yourApiToken,
request: {
proxy: process.env.MY_PROXY,
},
});

app.get("/api/clan-by-tag", (req, res) => {
client
.clanByTag('#'+req.query.tag)
.then(response => res.end(response))
});

app.listen(3000);
BaiLinfeng
2020-12-16 23:56:14 +08:00
@YuxiangLuo 老铁写的这个 get 路径是几个意思?没明白,还有你这个 proxy 代理,这里可以不使用代码吗?
iamyow
2020-12-17 00:42:10 +08:00
github 上不是写得很清楚了吗?安装、注册,再配置你的 nodejs 项目 token,然后 request-promise 的写法,都有例子啊。最后还有个手把手教你的链接。
BaiLinfeng
2020-12-17 13:20:23 +08:00
@iamyow 表示没看懂,难受
iamyow
2020-12-18 00:33:06 +08:00
BaiLinfeng
2020-12-19 17:52:08 +08:00
@iamyow 这个教程我看了,还是没有弄出来。不知道怎么使用了。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/736197

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX