Skip to content

客户API消息回复

Eric edited this page Mar 28, 2016 · 1 revision

客服API消息回复

var service = nodeWeixinMessage.service;


//回复文本消息
service.api.text(app, process.env.APP_OPENID, 'hello', function (error, data) {
  //data.errcode
  //data.errmsg
});

//回复图片
service.api.image(app, process.env.APP_OPENID, mediaId, function (error, data) {
  //data.errcode
  //data.errmsg
});

//回复语音
service.api.voice(app, process.env.APP_OPENID, mediaId, function (error, data) {
  //data.errcode
  //data.errmsg
});

//回复视频
service.api.video(app, process.env.APP_OPENID, 'title', 'desc',
 mediaId, thumbMediaId, function (error, data) {
  //data.errcode
  //data.errmsg
});

//回复音乐
service.api.music(app, process.env.APP_OPENID,
  'http://www.stephaniequinn.com/Music/Commercial%20DEMO%20-%2015.mp3',
  'http://www.stephaniequinn.com/Music/Commercial%20DEMO%20-%2015.mp3',  //高品质音乐URL
  thumbMediaId,
  'title',
  'desc', function (error, data) {
    //data.errcode
    //data.errmsg
  });

//回复图文
var articles = [
  {
    "title": "Happy Day",
    "description": "Is Really A Happy Day",
    "url": "http://www.qq.com",
    "picurl": "https://mp.weixin.qq.com/cgi-bin/singlesendpage?t=message/send&action=index&tofakeid=1866487131&token=1650197120&lang=zh_CN"
  },
  {
    "title": "Happy Day",
    "description": "Is Really A Happy Day",
    "url": "http://www.qq.com",
    "picurl": "https://mp.weixin.qq.com/cgi-bin/singlesendpage?t=message/send&action=index&tofakeid=1866487131&token=1650197120&lang=zh_CN"
  }
];

service.api.news(app, process.env.APP_OPENID, articles, function (error, data) {
  //data.errcode
  //data.errmsg
});
Clone this wiki locally