Skip to content

Commit 5106f12

Browse files
黄志东黄志东
authored andcommitted
[new]新增sendMpNews接口
1 parent 0d5b317 commit 5106f12

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

lib/api_message.js

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ exports.sendMusic = function* (openid, music) {
201201
};
202202

203203
/**
204-
* 客服消息,发送图文消息
204+
* 客服消息,发送图文消息(点击跳转到外链)
205205
* 详细细节 http://mp.weixin.qq.com/wiki/index.php?title=发送客服消息
206206
* Examples:
207207
* ```
@@ -256,6 +256,34 @@ exports.sendNews = function* (openid, articles) {
256256
return yield this.request(url, postJSON(data));
257257
};
258258

259+
/**
260+
* 客服消息,发送图文消息(点击跳转到图文消息页面)
261+
* 详细细节 http://mp.weixin.qq.com/wiki/14/d9be34fe03412c92517da10a5980e7ee.html#.E5.AE.A2.E6.9C.8D.E6.8E.A5.E5.8F.A3-.E5.8F.91.E6.B6.88.E6.81.AF
262+
* Examples:
263+
* ```
264+
* api.sendMpNews('openid', 'mediaId');
265+
* ```
266+
* Callback:
267+
*
268+
* - `err`, 调用失败时得到的异常
269+
* - `result`, 调用正常时得到的对象
270+
*
271+
* @param {String} openid 用户的openid
272+
* @param {String} mediaId 图文素材id
273+
*/
274+
exports.sendMpNews = function* (openid, mediaId) {
275+
var token = yield this.ensureAccessToken();
276+
var url = this.prefix + 'message/custom/send?access_token=' + token.accessToken;
277+
var data = {
278+
'touser': openid,
279+
'msgtype':'mpnews',
280+
'mpnews': {
281+
'media_id': mediaId
282+
}
283+
};
284+
return yield this.request(url, postJSON(data));
285+
};
286+
259287
/**
260288
* 获取自动回复规则
261289
* 详细请看:<http://mp.weixin.qq.com/wiki/19/ce8afc8ae7470a0d7205322f46a02647.html>

0 commit comments

Comments
 (0)