Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bugfix]设备授权接口没有传入产品编号 #42

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion lib/api_device.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@ exports.createDeviceQRCode = function* (deviceIds) {
return yield this.request(url, postJSON(info));
};

exports.authorizeDevices = function* (devices, optype) {
/**
* 设备授权接口
* 详情请见:<http://iot.weixin.qq.com/wiki/new/index.html?page=3-4-5>
* @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;
Expand All @@ -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));
};

Expand Down
30 changes: 29 additions & 1 deletion lib/api_message.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ exports.sendMusic = function* (openid, music) {
};

/**
* 客服消息,发送图文消息
* 客服消息,发送图文消息(点击跳转到外链)
* 详细细节 http://mp.weixin.qq.com/wiki/index.php?title=发送客服消息
* Examples:
* ```
Expand Down Expand Up @@ -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));
};

/**
* 获取自动回复规则
* 详细请看:<http://mp.weixin.qq.com/wiki/19/ce8afc8ae7470a0d7205322f46a02647.html>
Expand Down