Skip to content

用中间件的方式直接调用微信第三方平台服务

Notifications You must be signed in to change notification settings

scout9ll/wx-component-middleware

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Usage

koa

import Koa from "koa";
import wxComponentService from "wx-component-service";

const app = new Koa();

wxComponentService(
  app,
  // weixin component config
  {
    componentAppSecret: "****",
    componentAppId: "****",
    token: "****",
    encodingAESKey: "****",
  },
  // redis config
  {
    host: "your_redis_host",
    port: 6379,
    db: 20,
    password: "****",
  }
);

// registe route for revicing component_ticket
import KoaRouter from "koa-router";
const router = new KoaRouter();
router.post("/notify", async (ctx, next) => {
  const wxc = ctx.wxc;
  const ticket = await wxc.decodeTicket(ctx.request.xml);
  console.log(ticket);
  ctx.body = "success";
});

app.use(router.routes());

app.listen(8008);

About

用中间件的方式直接调用微信第三方平台服务

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published