|
[插件使用]
ajSms(极光短信)demo分享
[复制链接]
ajSms 本模块封装了极光短信SDK,获取短信,语音验证码,校验短信。
前端代码示例:
- <!DOCTYPE HTML>
- <html>
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="maximum-scale=1.0, minimum-scale=1.0, user-scalable=0, initial-scale=1.0, width=device-width"/>
- <meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
- <title>ajSms</title>
- <link rel="stylesheet" type="text/css" href="css/api.css" />
- <link rel="stylesheet" type="text/css" href="css/box.css" />
- <script type="text/javascript" src="script/public.js"></script>
- <style>
- button,input{
- width:200px;
- }
- #main{
- padding-top:100px;
- text-align:center;
- }
- </style>
- <script type="text/javascript">
-
- var demo = null;
- apiready = function(){
- demo = api.require('ajSms');
- }
-
- function init(){
- var param = {debug:false,appKey:'your appKey'};
- demo.init(param, function(ret, err){
- alert(JSON.stringify(ret));
- });
- }
- function getSmsCode(){
- var param = {phone:'1371711245'};
- demo.getSmsCode(param, function(ret, err){
- alert(JSON.stringify(ret));
- });
- }
-
- function getVoiceCode(){
- var param = {phone:'1371711245'};
- demo.getVoiceCode(param, function(ret, err){
- alert(JSON.stringify(ret));
- });
- }
-
- function checkSmsCode(){
- var param = {phone:'1371711245',sec:document.getElementById('sec').value};
- demo.checkSmsCode(param, function(ret, err){
- alert(JSON.stringify(ret));
- });
- }
- </script>
- </head>
- <body>
- <div id="wrap">
- <div id="main">
- <button onclick="init()">init()</button><br><br>
- <button onclick="getSmsCode()">getSmsCode()</button><br><br>
- <button onclick="getVoiceCode()">getVoiceCode()</button><br><br>
- <button onclick="checkSmsCode()">checkSmsCode()</button><br><br>
- <input id='sec' placeholder="短信验证码" type='text'/>
- </div>
- </div>
- </body>
- </html>
复制代码 如有问题,欢迎在下方留言讨论,谢谢支持。
|
|