|
|
const request = require('request-promise');
|
|
|
const Promise = require('bluebird');
|
|
|
const logger = require('../../../library/logger');
|
|
|
|
|
|
const appId = '';
|
|
|
const secret = '';
|
|
|
|
|
|
const wechat = {
|
|
|
getAccessToken: Promise.coroutine(function* () {
|
|
|
return request({
|
|
|
url: 'https://api.weixin.qq.com/cgi-bin/token',
|
|
|
qs: {
|
|
|
grant_type: 'client_credential',
|
|
|
appid: appId,
|
|
|
secret: secret
|
|
|
}
|
|
|
}).catch((err) => {
|
|
|
logger.error('微信分享 Token, 获取 accessToken 时出错', JSON.stringify(err));
|
|
|
});
|
|
|
}),
|
|
|
|
|
|
getTicket: Promise.coroutine(function* (accessToken) {
|
|
|
return request({
|
|
|
url: 'https://api.weixin.qq.com/cgi-bin/ticket/getticket',
|
|
|
qs: {
|
|
|
access_token: accessToken,
|
|
|
type: 'jsapi'
|
|
|
}
|
|
|
}).catch((err) => {
|
|
|
logger.error('微信分享 Token, 获取 ticket 时出错', JSON.stringify(err));
|
|
|
});
|
|
|
}),
|
|
|
|
|
|
calcSignature: Promise.coroutine(function* () {
|
|
|
return yield Promise.resolve(true);
|
|
|
})
|
|
|
};
|
|
|
|
|
|
module.exports = wechat; |
...
|
...
|
|