npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

wechat-node-sdk

v0.2.2

Published

微信公众平台NodeJS开发包, weixin developer SDK for NodeJS.

Downloads

29

Readme

wechat-node-sdk

微信公众平台NodeJS开发包, weixin developer SDK for NodeJS.

微信官方技术文档

微信公众平台: http://mp.weixin.qq.com/wiki/

微信企业平台: http://qydev.weixin.qq.com/wiki/

微信支付接入文档: https://mp.weixin.qq.com/cgi-bin/readtemplate?t=business/course2_tmpl&lang=zh_CN

微信多客服: https://mpkf.weixin.qq.com/

参考文档

参考 Wechat-php-sdk(https://github.com/dodgepudding/wechat-php-sdk)

内部文档

被动回复消息 0.1.0+ (文档整理中)

获取access_token 0.2.0+ 文档

客服消息 0.2.0+ 文档

安装

npm install wechat-node-sdk

初始化基本代码

var options = {
      'token':'tokenaccesskey',           //填写你设定的Token
      'encodingaeskey':'encodingaeskey',  //填写加密用的EncodingAESKey
      'appid':'wxappid',                  //填写高级调用功能的appid
      'appsecret':'xxxxxxxxxxxxxxxxxxx'   //填写高级调用功能的密钥
    };

var wechat = require('wechat-node-sdk');

var wx = new wechat(options);
//TODO:调用wx各实例方法

Using with Express 3/4

var app = require('express')();
var server = require('http').Server(app);
var wechat = require('wechat-node-sdk');

server.listen(6658, '127.0.0.1');

app.use('/wechat', _handler );


var options = {
    'token':'tokenaccesskey',           //填写你设定的Token
    'encodingaeskey':'encodingaeskey',  //填写加密用的EncodingAESKey
    'appid':'wxappid',                  //填写高级调用功能的appid
    'appsecret':'xxxxxxxxxxxxxxxxxxx'   //填写高级调用功能的密钥
};
    
var wx = new wechat(options);    
wx.on('ready', function (_wechat, req, res) {
    var data = _wechat.getRevData();
    console.log('收到的内容:',data);
    data = JSON.stringify(data);
    _wechat.text('你好!' + data).reply();
});  
  
  
function _handler(req, res){
    wx.run(req, res);
}

Using with Node http server

var http = require("http");
var url = require("url");
var qs = require("querystring");
var wechat = require("wechat-node-sdk");


//微信公众号相关配置参数
var options = {
    'token':'tokenaccesskey',           //填写你设定的Token
    'encodingaeskey':'encodingaeskey',  //填写加密用的EncodingAESKey
    'appid':'wxappid',                  //填写高级调用功能的appid
    'appsecret':'xxxxxxxxxxxxxxxxxxx'   //填写高级调用功能的密钥
};


//实例化微信类
var wx = new wechat(options);

//监听ready事件,将回复消息的业务逻辑写在这里的回调方法里
wx.on('ready', function (_wechat, req, res) {
    console.log('我收到的数据是:', _wechat.getRevData() );
    //todo some thing
});


http.createServer(function (req, res) {
    var _url = url.parse(req.url);
    var _query = qs.parse(_url.query);
    var originalUrl = _url.pathname;

    if (originalUrl == '/wechat') {
        wx.run(req, res); 
    } else {
        res.writeHead(200, {
            "content-type": "text/plain"
        });
        res.write("hello wechat!");
        res.end();
    }
}).listen(3000);