作者:天眞啲笨尛孩 | 来源:互联网 | 2023-09-05 12:56
eggjs 实现腾讯云短信调用
在腾讯云后台获取 secretId 和 secretKey
![在腾讯云后台获取 secretId 和 secretKey](https://img.php1.cn/3cd4a/1e618/c5a/d5d40da532c3a782.png)
获取 SmsSdkAppId (就是SDKAppID)
![在这里插入图片描述](https://img.php1.cn/3cd4a/1eebe/cd5/617c1173853af4b6.webp)
获取SignName 直接复制中文就可以(签名要审核通过的才可以)
![在这里插入图片描述](https://img.php1.cn/3cd4a/9b0d/ae9/2d998ad7838fbf16.jpeg)
获取 TemplateId 要审核过的模板
![在这里插入图片描述](https://img.php1.cn/3cd4a/18ace/696/1d8e759bd3e6bbec.jpeg)
代码片
.
async eapi() {const tencentcloud = require("tencentcloud-sdk-nodejs");const SmsClient = tencentcloud.sms.v20210111.Client;const clientConfig = {credential: {secretId: "xxxxxxxxxxxxxxx填写自己的",secretKey: "xxxxxxxxxxxxxx填写自己的",},region: "ap-nanjing",profile: {httpProfile: {endpoint: "sms.tencentcloudapi.com",},},};const client = new SmsClient(clientConfig);const params = {"PhoneNumberSet": ["+86手机号","+86手机号"],"SmsSdkAppId": "xxxxx要填写自己的","SignName": "xxxx要填写自己的","TemplateId": "xxxx要填写自己的","TemplateParamSet": ["xxxx六位数字随便填"]};client.SendSms(params).then((data) => {console.log(data);},(err) => {console.error("error", err);});}
这是短信的的调用,如果需要实现注册短信验证还需要自己写