falcondai / wechat-nodejs-guide

a nodejs guide to integrating with the wechat (weixin) platform
5 stars 2 forks source link

guide to integrating with wechat (weixin) platform

Wechat is one of the largest messaging app by user count but its API and docs are not very developer-friendly. It is especially hard for non-Chinese speaking developers. This guide is my attempt to save others some pain and effort. Some solutions are opinionated and you are welcome to submit your suggestions via issues.

public accounts

To register a (personal) public account, you will need a Chinese national ID. And there is a quota (currently 5) on how many accounts each ID can create. If you just want to play with the public account API and test your integration, you should start with the official sandboxed test accounts which only requires you to have a wechat account to create.

register a test account

setup webhook

var express = require('express');
var wechat = require('wechat');

var app = express();

app.use('/wechat', wechat('token', function (req, res, next) {
  // message is located in req.weixin
  var message = req.weixin;
  console.log(message);
}));

app.listen(3000);