| 主機參考: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");//發起訪問請求$ 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&。#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}
這幾篇文章你可能也喜歡:
- 如何自動將內容從Dreamweaver網站更新為Sina Weibo(如何使用Dreamweaver)
- 如何在Dreamweaver CMS中為圖像集的縮略圖實施分頁樣式(如何在Dreamweaver主頁中更改照片)
- 如何自動更新Dreamweaver主頁功能(Dreamweaver Active Push插件)
- 如何使用{dede:field.body/}刪除P元素
- 如果Dreamweaver Collection不會自動生成摘要和關鍵字(Dreamweaver自動收集和自動出版插件)
本文由主機參考刊發,轉載請注明:如何實現織夢短信的驗證碼功能(織夢官方) http://www.k2270.com/118627.html
主機參考

















評論前必須登錄!
注冊