我选择的短信平台是榛子云短信,具体可看文档/doc/sdk.html
准备工作
下载zhenzisms.js文件并导入到所使用的js文件中有个自己的AppId、AppSecret
zhenzisms.client.init('', '105954', '密码');var params = {};params.number = '13093944163';//捕捉前端输入的接受方手机号params.templateId = '438';//模板编号//438编号模板是: 验证码:{1},{2}内有效,请勿泄漏给他人使用。var code = zhenzisms.client.createCode(4, 60, params.number);//生成验证码var templateParams = [code, '5分钟'];params.templateParams = templateParams;// params.messageId = '1111111';//可不选,短信的唯一标识// params.clientIp = '221.221.221.111';//可不选,console.log(code);zhenzisms.client.send(function (res) {wx.showToast({title: res.data.data,icon: 'none',duration: 2000})}, params);
请求参数