yixin

1.0.3 • Public • Published

node-yixin

易信公众帐号api,参考wechat

功能列表

  • 接收用户发送信息(文本,图片,语音,视频,音乐,地理位置,事件消息)
  • 自动回复(文本,图片,音乐,图文)
  • 客服消息(文本,图片,语音,视频,链接,名片,图文消息)
  • 群组消息(文本,图文,名片)
  • 菜单操作(查询、创建、删除)
  • 二维码(创建临时、永久二维码,查看二维码URL)
  • 分组操作(查询、创建、修改、移动用户到分组)
  • 用户信息(查询用户基本信息、获取关注者列表)
  • OAuth API(授权、获取基本信息)
  • 媒体文件(上传、获取)

Install

npm install yixin

Use with Connect/Express

//...
var Yixin = require('./');
var yixin = new Yixin('token');
app.configure(function() {
  app.use(express.query());
  app.use('/yinxin', yixin.middleware);
  yixin
    .text(function(req, res) {
      var message = req.yixin; //用户的消息通过`req.yixin`获取
      res.reply('hello world');
    })
    .image(function(req, res) {
      //...
    });
  //...
});
 
 
//...

回复消息

当用户发送消息到微信公众账号,自动回复一条消息。这条消息可以是文本、图片、音乐、图文。详见:官方文档

回复文本

res.reply('Hello world!');
// 或者
res.reply({type: "text", content: 'Hello world!'});

回复图片

res.reply({
  type: "image",
  content: {
    mediaId: 'mediaId'
  }
});

回复音乐

res.reply({
  description: "一无所有",
  musicUrl: "http://mp3.com/xx.mp3",
  hqMusicUrl: "http://mp3.com/xx.mp3"
});

回复图文

res.reply([
  {
    title: '你来我家接我吧',
    description: '这是女神与高富帅之间的对话',
    picurl: 'http://nodeapi.cloudfoundry.com/qrcode.jpg',
    url: 'http://nodeapi.cloudfoundry.com/'
  }
]);

Readme

Keywords

Package Sidebar

Install

npm i yixin

Weekly Downloads

11

Version

1.0.3

License

none

Last publish

Collaborators

  • sunfuze
  • hujb2000