Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

wechat-corp-service-callback

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wechat-corp-service-callback

A callback interface for wechat 3rd corp service.

latest
Source
npmnpm
Version
0.0.1
Version published
Maintainers
1
Created
Source

wechat corp service callback

微信公共平台企业号版(第三方企业套件)SDK-回调接口

功能说明

用来接收企业第三方应用套件发送过来的回调消息。

安装方法

$ npm install wechat-corp-service-callback

使用方法

前提

首先,你要有一个企业号。 然后,你要申请成为第三方企业套件的供应商。 接下来才可以创建套件,并且设置套件应用。

用法

其中的token,encodingAESKey,suite_id可以在套件的信息配置界面获取。

var wechat_cs = require('wechat-corp-service-callback');

var app_suite = function(req, res, next) {
    var _config = {
        token: sc.token,
        encodingAESKey: sc.encodingAESKey,
        suiteid: sc.suite_id,
    };
    var _route = function(message, req, res, next) {
        
        if (message.InfoType == 'suite_ticket') { //微信服务器发过来的票,每10分钟发一次
            //更新到数据库
            var suite_ticket = message.SuiteTicket;
            var suite_ticket_tm = new Date(parseInt(message.TimeStamp) * 1000);
            //将最新的ticket放到数据库中, 调用用户自己定义的 save_ticket(callback) 方法。
             save_ticket(function(err, ret) {
                res.reply('success');
            });
        } else if (message.InfoType == 'change_auth') { //变更授权的通知
            //更新到数据库
            res.reply('success');

        } else if (message.InfoType == 'cancel_auth') { //取消授权的通知
            //更新到数据库
            res.reply('success');
        } else {
            res.reply('success');
        };
    }
    if (req.method == 'POST') {
        wechat_cs(_config, _route)(req, res, next);
    } else if (req.method == 'GET') {
        res.send('这个接口不适合GET');
    };
}

app.get(__base_path + '/app_suite_callback', app_suite);
app.post(__base_path + '/app_suite_callback', app_suite);

相关文档

  • 微信企业号-第三方应用授权

License

The MIT license.

交流群

QQ群:157964097,使用疑问,开发,贡献代码请加群。

感谢

感谢以下贡献者:

捐赠

如果您觉得Wechat企业号版本对您有帮助,欢迎请作者一杯咖啡

捐赠wechat

FAQs

Package last updated on 04 May 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts