更新云函数

This commit is contained in:
唐明明
2021-07-26 12:05:57 +08:00
parent a6b92679c2
commit 6f29bdc89f
6 changed files with 3706 additions and 3513 deletions

View File

@@ -1,11 +1,37 @@
'use strict';
exports.main = async (event, context) => {
return await uniCloud.getPhoneNumber({
appid: '__UNI__CD19AAD',
provider: 'univerify',
apiKey : '16fa20236696596869759d3a81541901', // 在开发者中心开通服务并获取apiKey
apiSecret: 'fca97287360c2e8f8259d8877a601887', // 在开发者中心开通服务并获取apiSecret
access_token: event.access_token,
openid: event.openid
})
'use strict';
const crypto = require('crypto')
exports.main = async (event) => {
const secret = 'Yuzhankeji2021.'
const hmac = crypto.createHmac('sha256', secret);
let params = event.queryStringParameters
const sign = params.sign
delete params.sign
const signStr = Object.keys(params).sort().map(key => {
return `${key}=${params[key]}`
}).join('&')
hmac.update(signStr);
if (sign !== hmac.digest('hex')) {
throw new Error('非法访问')
}
const {
access_token,
openid
} = params
return await uniCloud.getPhoneNumber({
appid: '__UNI__CD19AAD',
provider: 'univerify',
apiKey: '16fa20236696596869759d3a81541901',
apiSecret: 'fca97287360c2e8f8259d8877a601887',
access_token: access_token,
openid: openid,
})
};