VPS参考测评推荐
专注分享VPS主机优惠信息
衡天云优惠活动

如何实现织梦短信的验证码功能(织梦官方)

主机参考:VPS测评参考推荐/专注分享VPS服务器优惠信息!若您是商家可以在本站进行投稿,查看详情!此外我们还提供软文收录、PayPal代付、广告赞助等服务,查看详情!
我们发布的部分优惠活动文章可能存在时效性,购买时建议在本站搜索商家名称可查看相关文章充分了解该商家!若非中文页面可使用Edge浏览器同步翻译!PayPal代付/收录合作

如何实现织梦短信的验证码功能(织梦官方)

如何实现织梦短信的验证码功能?

目前,大多数网站都需要使用短信验证码。因为Dreamweaver官方没有短信验证码插件,所以他们编写了几个短信验证码插件,一个使用阿里云的短信验证码接口,另一个使用阿里的短信验证码接口,另一个使用云智讯的短信接口。

推荐学习:梦想编织cms

以下教程包含2个织梦短信验证码的接口。

Dreamweaver成员的SMS注册需要修改的地方:

1.需要创建一个表格来记录验证码,并防止多次发送。这里创建了一个phonecode表。

2.member/templates/reg-new.htm(注册模板以添加元素)

3.member/templates/js/reg _ new.js(验证手机号码)

4.member/index_do.php(根据后台设置,判断是否发送注册验证码)。

5.member/reg_new.php(验证、记录)

A.使用阿里云短信界面访问:

需要在会员/指数_ do.php的相应位置插入阿里云短信接口代码。特别需要注意的是,阿里云短信的官方演示文档是由大神编写的,因此普通人在使用时会报告名称空间错误,这需要他们自己注意。此外,短信模板需要更新。现在阿里短信模板的审核很严格,不允许有其他变量。以前没有这个问题。因此,当审计失败时,有必要减少变量。(目前无法打开阿里云短信界面,新打开的阿里通信界面。这个码不能用,只适合很久以前通过阿里云开通短信的人。)

function getrandchar($ length){ $ str = null;$ strPol = & quot0123456789 abcdefghijklmnopqrstuvwxyz & quot;;$ max = strlen($ strPol)-1;for($ I = 0;$ i & lt$ length$ i++){ $ str。= $ strPol【rand(0,$ max)】;} return $ str} $ code = getrandchar(5);require _ once(dede Inc。& amp#39;/阿里云-PHP-SDK-core/config . PHP & amp;#39;);使用短信\请求\V20160927作为短信;$ iclient profile = default profile::get profile(& quot;cn-深圳& quot,& quot您的访问密钥& quot,& quot您的访问机密& quot);//登录阿里云查看:“您的accessKey & quot,& quot您的访问机密& quot$ client = new DefaultAcsClient($ iclient profile);$ request = new Sms \ SingleSendSmsRequest();$ request-& gt;setSignName(& quot;签名“);/*签名名称*/$ request-& gt;setTemplateCode(& quot;SMS _ 1111 & quot);/*模板代码*/$ request-& gt;setRecNum($ phone);/*目标手机号码*/$ request-& gt;setParamString(& quot;{ \ & quot代码\ & quot:\ & quot$ code \ & quot,\ & quot电话\ & quot:\ & quot电话号码\ & quot} & quot);/*模板变量,请确保它与批准的SMS模板变量一致,并且数字必须转换为字符串*/try { $ response = $ client-& gt;getAcsResponse($ request);print _ r(response);} catch(client exception $ e){ print _ r($ e-& gt;get error code());print _ r($ e-& gt;get error message());} catch(server exception $ e){ print _ r($ e-& gt;get error code());print _ r($ e-& gt;get error message());} $ inquery = & quot插入` dede _ phonecode `(` IP `,` phone `,` phone code `,` used `,` sendtime `)值(& amp#39;$ ip & amp#39;,& amp#39;$ to & amp#39;,& amp#39;$ code & amp#39;,& amp#39;1 & amp#39;,& amp#39;$ nowtime & amp#39;);";$ RS = $ dsql-& gt;executonequery2($ inquery);if($ RS = 1){ ShowMsg(& amp;#39;发送成功,请注意查收!& amp#39;,& amp#39;-1 & amp;#39;);exit();} exit();附上阿里云短信模板:验证码:${code}。您正在注册。如果不是你自己做的,请忽略此消息。如有任何问题,请联系我们!电话:${tel}

B.使用阿里鱼的短信界面访问:

同样,您需要在member/index_do.php的相应位置插入以下代码。

function getrandchar($ length){ $ str = null;//$ strPol = & quot;abcdefghijklmnopqrstuvwxyz 0123456789 abcdefghijklmnopqrstuvwxyz & quot;;$ strPol = & quot0123456789 abcdefghijklmnopqrstuvwxyz & quot;;$ max = strlen($ strPol)-1;for($ I = 0;$ i & lt$ length$ i++){ $ str。= $ strPol【rand(0,$ max)】;} return $ str} $ code = getrandchar(5);require _ once(dede Inc。& amp#39;/alidayu-PHP-SDK/topsdk . PHP & amp;#39;);$ client = new TopClient$ client-& gt;appkey = & amp#39;111111 & amp#39;;//登录阿里大于查看appkey。$ client-& gt;secretKey = & amp#39;aaaaaaaaaaaaaa & amp#39;;//登录阿里大于查看秘籍。$ req = new AlibabaAliqinFcSmsNumSendRequest;$ req-》;setExtend(& quot;");$ req-》;sets mstype(& quot;正常& quot);$ req-》;setSmsFreeSignName(& quot;城子居& quot);/*签名名称*/$ req-& gt;setSmsParam(& quot;{ \ & quot代码\ & quot:\ & quot$ code \ & quot,\ & quot名称\ & quot:\ & quot注册\ & quot} & quot);/*模板变量,请确保与批准的SMS模板变量一致,并且数字必须转换为字符串*/$ req-& gt;setRecNum($ phone);/*目标手机号码*/$ req-& gt;setSmsTemplateCode(& quot;SMS _ 1111111 & quot);//登录Ali大于视图/*模板ID号*/$ resp = $ client-& gt;execute($ req);$ inquery = & quot插入` IMM _ phonecode `(` IP `,` phone `,` phone code `,` used `,` sendtime `)值(& amp#39;$ ip & amp#39;,& amp#39;$ to & amp#39;,& amp#39;$ code & amp#39;,& amp#39;1 & amp#39;,& amp#39;$ nowtime & amp#39;);";$ RS = $ dsql-& gt;executonequery2($ inquery);if($ RS = 1){ ShowMsg(& amp;#39;发送成功,请注意查收!& amp#39;,& amp#39;-1 & amp;#39;);exit();} exit();c .使用最新的阿里通信短信接口访问:

function getrandchar($ length){ $ str = null;//$ strPol = & quot;abcdefghijklmnopqrstuvwxyz 0123456789 abcdefghijklmnopqrstuvwxyz & quot;;$ strPol = & quot0123456789 & quot;$ max = strlen($ strPol)-1;for($ I = 0;$ i & lt$ length$ i++){ $ str。= $ strPol【rand(0,$ max)】;} return $ str} $ number = getrandchar(4);require _ once(dede Inc。& amp#39;/阿里云-PHP-SDK-core/config . PHP & amp;#39;);require _ once(dede Inc。& amp#39;/Dysmsapi/Request/v 2017 05 25/sendsmsrequest . PHP & amp;#39;);require _ once(dede Inc。& amp#39;/Dysmsapi/Request/v 2017 05 25/query send details Request . PHP & amp;#39;);函数sendSms(){ global $ phone,$ number//您需要用自己的AK信息替换它$ access keyid =“your access keyid & quot;;$ accessKeySecret = & quotyourAccessKeySecret & quot;//SMS API产品名称$ product =“Dysmsapi & quot;;//SMS API产品域名$ domain =“dysmsapi . aliyuncs . com & quot;;//多地区$ Region =“cn-Beijing & quot;;//ACSCLEINT $ PROFILE = DEFAULT PROFILE::GET PROFILE($ REGION,$ ACCESS KEYID,$ ACCESS KEYSECRET)用于初始化ACCESS;default profile::add endpoint(& quot;cn-北京& quot,& quotcn-北京& quot,$product,$ domain);$ ACS client = new DefaultAcsClient($ profile);$ Request = new Dysmsapi \ Request \ v 2017 05 25 \ SendSmsRequest;//必需-短信接收号码$ request-& gt;set phone numbers($ phone);//必需的-SMS签名$ request-& gt;setSignName(& quot;99店铺网“);//必需的-SMS模板代码$ request-& gt;setTemplateCode(& quot;SMS _ 74725029 & quot);//可选-必需(JSON格式)$ request-& gt;setTemplateParam(& quot;{ \ & quot号码\ & quot:\ & quot$ number \ & quot} & quot);//可选-发送短信序列号$ request-& gt;setOutId(& quot;1234&quot);//发起访问请求$ ACS response = $ ACS client-》;getAcsResponse($ request);} sendSms();$ inquery = & quot插入` IMM _ phonecode `(` IP `,` phone `,` phone code `,` used `,` sendtime `)值(& amp#39;$ ip & amp#39;,& amp#39;电话& amp#39;,& amp#39;$number英镑#39;,& amp#39;1 & amp#39;,& amp#39;$ nowtime & amp#39;);";$ RS = $ dsql-& gt;executonequery2($ inquery);if($ RS = 1){ echo & quot;发送成功,请注意查收!";exit();} exit();在这里,阿里的三个短信接口都在这里,对应的SDK需要在阿里云中找到并下载。

d .使用云智迅的短信界面访问:

同样,您需要在member/index _ do.php的相应位置插入云智迅短信接口代码。

function getrandchar($ length){ $ str = null;$ strPol = & quot0123456789 abcdefghijklmnopqrstuvwxyz & quot;;$ max = strlen($ strPol)-1;for($ I = 0;$ i & lt$ length$ i++){ $ str。= $ strPol【rand(0,$ max)】;} return $ str} require _ once(dede Inc。& amp#39;/UCP AAS . class . PHP & amp;#39;);$期权【& amp#39;帐户id&amp。#39;】= & amp#39;& amp#39;;//对应ucpaas.com用户id $ options【&;#39;token & amp#39;】= & amp#39;& amp#39;;//对应ucpaas.com的用户令牌$ UC pass = new ucpaas($ options);$ appId = & quot";//对应于ucpaas.com的项目ID $ to = $ phone$ templateId = & quot";//对应于ucpaas.com的SMS模板ID $ code = getrandchar(5);$param= $code。& amp#39;,短信模板参数2 &;#39;。& amp#39;,短信模板参数3 &;#39;;// $code是生成的验证码、短信模板参数2和短信模板参数3,参数之间用英文逗号分隔。$ UC pass-& gt;template SMS($ appId,$to,$templateId,$ param);$ inquery = & quot插入` dede _ phonecode `(` IP `,` phone `,` phone code `,` used `,` sendtime `)值(& amp#39;$ ip & amp#39;,& amp#39;$ to & amp#39;,& amp#39;$ code & amp#39;,& amp#39;1 & amp#39;,& amp#39;$ nowtime & amp#39;);";$ RS = $ dsql-& gt;executonequery2($ inquery);if($ RS = 1){ ShowMsg(& amp;#39;发送成功,请注意查收!& amp#39;,& amp#39;-1 & amp;#39;);exit();} exit();同时附上短信模板:验证码:{1}。您位于{2}。如果不是你自己做的,请忽略此消息。如有任何问题,请联系我们!电话:{3}

这几篇文章你可能也喜欢:

本文由主机参考刊发,转载请注明:如何实现织梦短信的验证码功能(织梦官方) https://zhujicankao.com/118627.html

【腾讯云】领8888元采购礼包,抢爆款云服务器 每月 9元起,个人开发者加享折上折!
打赏
转载请注明原文链接:主机参考 » 如何实现织梦短信的验证码功能(织梦官方)
主机参考仅做资料收集,不对商家任何信息及交易做信用担保,购买前请注意风险,有交易纠纷请自行解决!请查阅:特别声明

评论 抢沙发

评论前必须登录!