项目作者: eggjs-community

项目描述 :
Wechat Api for Egg.js
高级语言: JavaScript
项目地址: git://github.com/eggjs-community/egg-wechat-api.git
创建时间: 2017-07-17T09:09:31Z
项目社区:https://github.com/eggjs-community/egg-wechat-api

开源协议:MIT License

下载


egg-wechat-api

NPM version
build status
Test coverage
David deps
Known Vulnerabilities
npm download

egg plugin for wechat-api

Install

  1. $ npm i egg-wechat-api --save

Prerequisite

Node.js >= 7.x

Usage

Dependencies

Configuration

  1. // {app_root}/config/plugin.js
  2. exports.wechatApi = {
  3. enable: true,
  4. package: 'egg-wechat-api',
  5. };

if redis is single client

  1. // {app_root}/config/config.default.js
  2. exports.wechatApi = {
  3. appId: '',
  4. appSecret: '',
  5. };

if redis is multi clients

  1. // {app_root}/config/config.default.js
  2. exports.wechatApi = {
  3. appId: '',
  4. appSecret: '',
  5. redisInstance: '', // select instance of redis
  6. };

Redis is required !

see config/config.default.js for more detail.

Example

  1. 'use strict';
  2. module.exports = app => {
  3. app.get('/', function* () {
  4. const { wechatApi } = app;
  5. try {
  6. const ticket = yield wechatApi.getTicket();
  7. this.status = 200;
  8. this.body = ticket;
  9. } catch (error) {
  10. this.status = 500;
  11. this.body = error;
  12. }
  13. });
  14. };

Questions & Suggestions

Please open an issue here.

License

MIT