Authored by ccbikai

微信 appid 修改

... ... @@ -11,13 +11,14 @@ const crypto = require('crypto');
const logger = require('../../../library/logger');
const cache = require('../../../library/cache');
const appId = 'wx75e5a7c0c88e45c2';
const secret = 'ce21ae4a3f93852279175a167e54509b';
// 此处请勿使用有货公众号的 appId, 此处使用的是 女生志 的appId
const appId = 'wx3de6d30e9567c227';
const secret = '1110772674e5751caad6563f2e9f0f53';
const sha1 = (etr) => {
const sha1 = (str) => {
const generator = crypto.createHash('sha1');
generator.update(etr);
generator.update(str);
return generator.digest('hex');
};
... ... @@ -55,7 +56,7 @@ const wechat = {
});
}),
getTicket: Promise.coroutine(function* (accessToken) {
getTicket: Promise.coroutine(function* () {
let ticket = yield cache.get(ticketCacheKey);
if (ticket) {
... ... @@ -66,7 +67,7 @@ const wechat = {
return request({
url: 'https://api.weixin.qq.com/cgi-bin/ticket/getticket',
qs: {
access_token: accessToken,
access_token: yield this.getAccessToken(),
type: 'jsapi'
},
json: true
... ... @@ -83,13 +84,12 @@ const wechat = {
}),
calcSignature: Promise.coroutine(function* (data) {
let accessToken = yield this.getAccessToken();
data = Object.assign({
noncestr: Math.random().toString(36).substr(2, 15),
timestamp: Math.floor(Date.now() / 1000) + '',
ticket: yield this.getTicket(accessToken)
ticket: yield this.getTicket()
}, data);
const str = `jsapi_ticket=${data.ticket}&noncestr=${data.noncestr}&timestamp=${data.timestamp}&url=${data.url}`;
data.signature = sha1(str);
... ...