From 0d5b317f0358d226a97017468d800b80c21c8deb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E5=BF=97=E4=B8=9C?= Date: Thu, 23 Feb 2017 18:44:16 +0800 Subject: [PATCH 1/2] =?UTF-8?q?[bugfix]=E8=AE=BE=E5=A4=87=E6=8E=88?= =?UTF-8?q?=E6=9D=83=E6=8E=A5=E5=8F=A3=E6=B2=A1=E6=9C=89=E4=BC=A0=E5=85=A5?= =?UTF-8?q?=E4=BA=A7=E5=93=81=E7=BC=96=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/api_device.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/api_device.js b/lib/api_device.js index 960bdae..bf0babf 100644 --- a/lib/api_device.js +++ b/lib/api_device.js @@ -42,7 +42,13 @@ exports.createDeviceQRCode = function* (deviceIds) { return yield this.request(url, postJSON(info)); }; -exports.authorizeDevices = function* (devices, optype) { +/** + * 设备授权接口 + * 详情请见: + * @param {Number} productID 产品编号 + * ``` + */ +exports.authorizeDevices = function* (devices, optype, productID) { var token = yield this.ensureAccessToken(); // https://api.weixin.qq.com/device/authorize_device?access_token=ACCESS_TOKEN var url = 'https://api.weixin.qq.com/device/authorize_device?access_token=' + token.accessToken; @@ -51,6 +57,9 @@ exports.authorizeDevices = function* (devices, optype) { 'device_list': devices, 'op_type': optype }; + if(productID){ + data.product_id = productID; + } return yield this.request(url, postJSON(data)); }; From 5106f12ebd4851e9bbbee3e3acf5e49c11436e45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E5=BF=97=E4=B8=9C?= Date: Thu, 23 Feb 2017 18:50:53 +0800 Subject: [PATCH 2/2] =?UTF-8?q?[new]=E6=96=B0=E5=A2=9EsendMpNews=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/api_message.js | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/lib/api_message.js b/lib/api_message.js index 6dfa6fc..7e7e4aa 100644 --- a/lib/api_message.js +++ b/lib/api_message.js @@ -201,7 +201,7 @@ exports.sendMusic = function* (openid, music) { }; /** - * 客服消息,发送图文消息 + * 客服消息,发送图文消息(点击跳转到外链) * 详细细节 http://mp.weixin.qq.com/wiki/index.php?title=发送客服消息 * Examples: * ``` @@ -256,6 +256,34 @@ exports.sendNews = function* (openid, articles) { return yield this.request(url, postJSON(data)); }; +/** + * 客服消息,发送图文消息(点击跳转到图文消息页面) + * 详细细节 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 + * Examples: + * ``` + * api.sendMpNews('openid', 'mediaId'); + * ``` + * Callback: + * + * - `err`, 调用失败时得到的异常 + * - `result`, 调用正常时得到的对象 + * + * @param {String} openid 用户的openid + * @param {String} mediaId 图文素材id + */ +exports.sendMpNews = function* (openid, mediaId) { + var token = yield this.ensureAccessToken(); + var url = this.prefix + 'message/custom/send?access_token=' + token.accessToken; + var data = { + 'touser': openid, + 'msgtype':'mpnews', + 'mpnews': { + 'media_id': mediaId + } + }; + return yield this.request(url, postJSON(data)); +}; + /** * 获取自动回复规则 * 详细请看: