目前小程序一个功能就是调用腾讯云短信的接口实现发送短信功能,目前经过本地调试,目标手机可以收到短信,但是关闭本地调试再次调用就会报错,想了解如何改进?
本人新手一枚,附上代码和报错:
报错图:
调用云函数代码:
let res = await wx.cloud.callFunction({
name: 'sendsms',
data: {
PhoneNumberSet: passengerParentNum,
TemplateParamSet: [passengerParentName,passengerName,orderID,carID,locationInfo]
}
})
云函数代码:
// 云函数入口文件
const tencentcloud = require("tencentcloud-sdk-nodejs");
const SmsClient = tencentcloud.sms.v20190711.Client;
const clientConfig = {
credential: {
secretId: "AXXXX0A5nXXXGTRBgwxiXXXXl12nJZZJoXXXXXW",
secretKey: "KPEoXXXXswkJcfS0XXXi14rPXXXXTgeX",
},
region: "ap-guangzhou",
profile: {
httpProfile: {
endpoint: "sms.tencentcloudapi.com",
},
},
};
const client = new SmsClient(clientConfig);
// 云函数入口函数
exports.main = async (event, context) => {
const params = {
"PhoneNumberSet" : [
'+86' + event.PhoneNumberSet
],
"TemplateID" : '1XXXXX1',
"Sign" : '毕业设计网约车实时定位',
"TemplateParamSet" : event.TemplateParamSet,
"SmsSdkAppid" : "14006XXXXX"
};
await client.SendSms(params).then((data) => {
console.log(data);
},
(err) => {
console.error("error",err);
});
return params
}