I have been working on an SMS platform recently, and I have tested Tencent Cloud's SMS platform, and recorded the feasible calling methods currently tested.
One: Preparation
Tencent Cloud SMS configuration process:
1. Register Tencent Cloud, real-name authentication (divided into individual and enterprise), purchase a package (free trial available)
2. Create an application, create a signature, (this part can be configured according to Tencent Cloud’s own documentation)
3 . Go to apis and create Tencent Cloud SMS API
4. Read the api interface documentation to understand configuration parameters and consider cross-domain issues.
Two: nodejs running implementation
download package
Run: npm install tencentcloud-sdk-nodejs-sms --save
Create smsTest.js
The code is roughly as follows:
const tencentcloud = require("tencentcloud-sdk-nodejs-sms");
const SmsClient = tencentcloud.sms.v20210111.Client;
const clientConfig = {
credential: {
secretId: "AKIDJn8I5gJwObaTDkW", //填自己的
secretKey: "fBUXMwHNDsITPlwxlO",//填自己的
},
region: "ap-nanjing",
profile: {
httpProfile: {
endpoint: "sms.tencentcloudapi.com",
},
},
};
// 实例化要请求产品的client对象,clientProfile是可选的
const client = new SmsClient(clientConfig);
function sendCont(){
const params = {
"PhoneNumberSet": [
"+8615572156567" //填自己的
],
"SmsSdkAppId": "140082459", //填自己的
"SignName": "测试", //填自己的
"TemplateId": "1822824", //填自己的
"TemplateParamSet": [
"A0080001" //填自己的
]
};
client.SendSms(params).then(
(data) => {
console.log(data);
},
(err) => {
console.error("error", err);
}
);
}
sendCont(); //直接运行 也可按需要自己调用
run
After node smsTest.js
runs, the return message SMS is sent successfully as follows