请问一下,上面那段代码你是怎么改写呢?
云函数可以发送阿里云短信么都是node.js,写的同样的代码,在阿里云的测试环境可以发送成功,在小程序的云函数里,返回成功,但是就是没收到短信,也没报错啥的。 什么原因呢? [代码]// 云函数入口文件[代码][代码]const[代码] [代码]cloud = require([代码][代码]'wx-server-sdk'[代码][代码]);[代码][代码]const[代码] [代码]Core = require([代码][代码]'@alicloud/pop-core'[代码][代码]);[代码][代码]cloud.init()[代码][代码]// 云函数入口函数[代码][代码]exports.main = async(event, context) => {[代码][代码] [代码][代码]var[代码] [代码]client = [代码][代码]new[代码] [代码]Core({[代码][代码] [代码][代码]accessKeyId: [代码][代码]'******'[代码][代码],[代码][代码] [代码][代码]accessKeySecret: [代码][代码]'******'[代码][代码],[代码][代码] [代码][代码]endpoint: [代码][代码]'https://dysmsapi.aliyuncs.com'[代码][代码],[代码][代码] [代码][代码]apiVersion: [代码][代码]'2017-05-25'[代码][代码] [代码][代码]});[代码][代码] [代码][代码]console.log([代码][代码]2[代码][代码]);[代码][代码] [代码][代码]var[代码] [代码]params = {[代码][代码] [代码][代码]"RegionId"[代码][代码]: [代码][代码]"cn-hangzhou"[代码][代码],[代码][代码] [代码][代码]"PhoneNumbers"[代码][代码]: [代码][代码]"139******195"[代码][代码],[代码][代码] [代码][代码]"SignName"[代码][代码]: [代码][代码]"******"[代码][代码],[代码][代码] [代码][代码]"TemplateCode"[代码][代码]: [代码][代码]"SMS_10******"[代码][代码],[代码][代码] [代码][代码]"TemplateParam"[代码][代码]: [代码][代码]'{"code":"445466"}'[代码][代码] [代码][代码]}[代码][代码] [代码][代码]console.log([代码][代码]3[代码][代码]);[代码][代码] [代码][代码]var[代码] [代码]requestOption = {[代码][代码] [代码][代码]method: [代码][代码]'POST'[代码][代码] [代码][代码]};[代码][代码] [代码][代码]console.log([代码][代码]4[代码][代码]);[代码][代码] [代码][代码]client.request([代码][代码]'SendSms'[代码][代码], params, requestOption).then((result) => {[代码][代码] [代码][代码]//console.log(result);[代码][代码] [代码][代码]return[代码] [代码]result[代码][代码] [代码][代码]}, (ex) => {[代码][代码] [代码][代码]return[代码] [代码]ex[代码][代码] [代码][代码]})[代码][代码] [代码][代码]console.log([代码][代码]5[代码][代码]);[代码][代码]}[代码]
2020-03-15