V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
BaiLinfeng
V2EX  ›  程序员

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

  •  1
     
  •   BaiLinfeng · 2020-12-16 23:07:54 +08:00 · 1935 次点击
    这是一个创建于 1198 天前的主题,其中的信息可能已经有所发展或是发生改变。

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

    6 条回复    2020-12-19 17:52:08 +08:00
    YuxiangLuo
        1
    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
        2
    BaiLinfeng  
    OP
       2020-12-16 23:56:14 +08:00
    @YuxiangLuo 老铁写的这个 get 路径是几个意思?没明白,还有你这个 proxy 代理,这里可以不使用代码吗?
    iamyow
        3
    iamyow  
       2020-12-17 00:42:10 +08:00
    github 上不是写得很清楚了吗?安装、注册,再配置你的 nodejs 项目 token,然后 request-promise 的写法,都有例子啊。最后还有个手把手教你的链接。
    BaiLinfeng
        4
    BaiLinfeng  
    OP
       2020-12-17 13:20:23 +08:00
    @iamyow 表示没看懂,难受
    BaiLinfeng
        6
    BaiLinfeng  
    OP
       2020-12-19 17:52:08 +08:00
    @iamyow 这个教程我看了,还是没有弄出来。不知道怎么使用了。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3454 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 00:45 · PVG 08:45 · LAX 17:45 · JFK 20:45
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.