帖子
帖子
用户
博客
课程
显示全部楼层
21
帖子
0
勋章
155
Y币

[插件使用] ajSms(极光短信)demo分享

[复制链接]
发表于 2019-11-27 16:14:33
ajSms 本模块封装了极光短信SDK,获取短信,语音验证码,校验短信。

运行图.jpg

前端代码示例:

  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <meta name="viewport" content="maximum-scale=1.0, minimum-scale=1.0, user-scalable=0, initial-scale=1.0, width=device-width"/>
  6.     <meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
  7.     <title>ajSms</title>
  8.     <link rel="stylesheet" type="text/css" href="css/api.css" />
  9.     <link rel="stylesheet" type="text/css" href="css/box.css" />
  10.     <script type="text/javascript" src="script/public.js"></script>
  11.     <style>
  12.             button,input{
  13.                     width:200px;
  14.             }
  15.             #main{
  16.                     padding-top:100px;
  17.                     text-align:center;
  18.             }
  19.     </style>
  20.         <script type="text/javascript">
  21.             
  22.                 var demo = null;
  23.                 apiready = function(){
  24.                     demo = api.require('ajSms');
  25.             }
  26.             
  27.                 function init(){
  28.                         var param = {debug:false,appKey:'your appKey'};
  29.                 demo.init(param, function(ret, err){
  30.                         alert(JSON.stringify(ret));
  31.                 });
  32.                 }

  33.                 function getSmsCode(){
  34.                         var param = {phone:'1371711245'};
  35.                 demo.getSmsCode(param, function(ret, err){
  36.                         alert(JSON.stringify(ret));
  37.                 });
  38.                 }
  39.                
  40.                 function getVoiceCode(){
  41.                         var param = {phone:'1371711245'};
  42.                 demo.getVoiceCode(param, function(ret, err){
  43.                         alert(JSON.stringify(ret));
  44.                 });
  45.                 }
  46.                
  47.                 function checkSmsCode(){
  48.                         var param = {phone:'1371711245',sec:document.getElementById('sec').value};
  49.                 demo.checkSmsCode(param, function(ret, err){
  50.                         alert(JSON.stringify(ret));
  51.                 });
  52.                 }
  53.         </script>
  54. </head>
  55. <body>
  56.     <div id="wrap">
  57.         <div id="main">
  58.                         <button onclick="init()">init()</button><br><br>
  59.                         <button onclick="getSmsCode()">getSmsCode()</button><br><br>
  60.                         <button onclick="getVoiceCode()">getVoiceCode()</button><br><br>
  61.                         <button onclick="checkSmsCode()">checkSmsCode()</button><br><br>
  62.                         <input id='sec' placeholder="短信验证码" type='text'/>
  63.                 </div>
  64.         </div>
  65. </body>
  66. </html>
复制代码
如有问题,欢迎在下方留言讨论,谢谢支持。

22
帖子
1
勋章
1万+
Y币
感谢分享
您需要登录后才可以回帖 登录

本版积分规则