From 7f545561d5e71fc3286c446bd8f6f4f2cf4d056d Mon Sep 17 00:00:00 2001 From: Finian Date: Mon, 11 Jun 2018 16:48:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20=20=E5=AE=A2=E6=9C=8D?= =?UTF-8?q?=E6=B6=88=E6=81=AF=EF=BC=8C=E5=8F=91=E9=80=81=E5=9B=BE=E6=96=87?= =?UTF-8?q?=E6=B6=88=E6=81=AF=EF=BC=88=E7=82=B9=E5=87=BB=E8=B7=B3=E8=BD=AC?= =?UTF-8?q?=E5=88=B0=E5=9B=BE=E6=96=87=E6=B6=88=E6=81=AF=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=EF=BC=89=E6=8E=A5=E5=8F=A3=20(#94)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/api_message.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/lib/api_message.js b/lib/api_message.js index efa6850..6ea9c23 100644 --- a/lib/api_message.js +++ b/lib/api_message.js @@ -254,6 +254,30 @@ exports.sendNews = async function (openid, articles) { return this.request(url, postJSON(data)); }; +/** + * 客服消息,发送图文消息(点击跳转到图文消息页面) + * 详细细节 https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140547 + * Examples: + * ``` + * api.sendMpNews('openid', 'mediaId'); + * ``` + + * @param {String} openid 用户的openid + * @param {String} mediaId 图文消息媒体文件的ID + */ +exports.sendMpNews = async function (openid, mediaId) { + const { accessToken } = await this.ensureAccessToken(); + var url = this.prefix + 'message/custom/send?access_token=' + accessToken; + var data = { + 'touser': openid, + 'msgtype':'mpnews', + 'mpnews': { + 'media_id': mediaId + } + }; + return this.request(url, postJSON(data)); +}; + /** * 获取自动回复规则 * 详细请看: