Skip to content

Commit 7f54556

Browse files
finianJacksonTian
authored andcommitted
新增 客服消息,发送图文消息(点击跳转到图文消息页面)接口 (#94)
1 parent 7637ae9 commit 7f54556

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

lib/api_message.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,30 @@ exports.sendNews = async function (openid, articles) {
254254
return this.request(url, postJSON(data));
255255
};
256256

257+
/**
258+
* 客服消息,发送图文消息(点击跳转到图文消息页面)
259+
* 详细细节 https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140547
260+
* Examples:
261+
* ```
262+
* api.sendMpNews('openid', 'mediaId');
263+
* ```
264+
265+
* @param {String} openid 用户的openid
266+
* @param {String} mediaId 图文消息媒体文件的ID
267+
*/
268+
exports.sendMpNews = async function (openid, mediaId) {
269+
const { accessToken } = await this.ensureAccessToken();
270+
var url = this.prefix + 'message/custom/send?access_token=' + accessToken;
271+
var data = {
272+
'touser': openid,
273+
'msgtype':'mpnews',
274+
'mpnews': {
275+
'media_id': mediaId
276+
}
277+
};
278+
return this.request(url, postJSON(data));
279+
};
280+
257281
/**
258282
* 获取自动回复规则
259283
* 详细请看:<http://mp.weixin.qq.com/wiki/19/ce8afc8ae7470a0d7205322f46a02647.html>

0 commit comments

Comments
 (0)