很多同学都有使用腾讯云发送短信功能,这我们已经使用代码做好,
全局JS文件为:
发送的按钮命令代码为:
- var random = randomPassword(10);
- var strMoblie = Forguncy.Page.getCell("mobile").getValue();
- var strAppKey = "APPKey";
- var strRand = random;
- var strTime = Date.parse(new Date()) / 1000;
- var sig = SHA256("appkey=" + strAppKey + "&random=" + strRand + "&time=" + strTime + "&mobile=" + strMoblie);
- var password = randomPassword(6);
- var data = {
- "ext": "",
- "extend": "",
- "params": [
- password
- ],
- "sig": sig,
- "sign": "西安葡萄城",
- "tel": {
- "mobile": strMoblie + "",
- "nationcode": "86"
- },
- "time": strTime,
- "tpl_id": "你的模板ID"
- };
- var newData = JSON.stringify(data);
- $.ajax({
- type: "post",
- url: "https://yun.tim.qq.com/v5/tlssmssvr/sendsms?sdkappid="+"这里写你的APPID"+"&random=" + random,
- async: false, // 使用同步方式
- // 1 需要使用JSON.stringify 否则格式为 a=2&b=3&now=14...
- // 2 需要强制类型转换,否则格式为 {"a":"2","b":"3"}
- data: newData,
- contentType: "application/json; charset=utf-8",
- dataType: "json",
- success: function (data) {
- console.log(data);
- }
- });
复制代码
|