hadsky是一个原创开源轻系统, 致力于为用户提供简单的解决方案。小编对他还是比较了解的,最近看到很多客户在找HadSky7.5版本的短信接口,今天小编就以新增短信接口为例,给大家讲解一下如何进行二次开发,我们今天讲解的是使用的短信接口是我们短信宝短信群发平台的短信接口,我们短信宝短信群发平台的接口非常稳定,发送速度快,注册就送测试短信,推荐大家使用
1:打开项目:\app\hadskycloudserver\setting.hst 新增短信宝页面代码
| 
						1 
						2 
						3 
						4 
						5 
						6 
						7 
						8 
						9 
						10 
						11 
						12 
						13 
						14 
						15 
						16 
						17 
						18 
						19 
						20 
						21 
						22 
						23 
						24 
						25 
						26 
						27 
						28 
						29 
						30 
						31 
						32 
						33 
						34 
						35 
						36 
						37 
						38 
						39 
						40 
						41 
						42 
						43 | <div class="pk-row pk-padding-bottom-15">    <label class="pk-w-sm-3 pk-padding-top-5 pk-text-bold pk-text-right pk-text-nowrap">短信宝用户名</label>    <div class="pk-w-sm-8">        <input class="pk-textbox"type="text"name="app_puyuetian_sms_smsbao_user"value="{$_G['SET']['APP_PUYUETIAN_SMS_SMSBAO_USER']}"placeholder="请填写短信宝用户名">    </div></div><div class="pk-row pk-padding-bottom-15">    <label class="pk-w-sm-3 pk-padding-top-5 pk-text-bold pk-text-right pk-text-nowrap">短信宝密码</label>    <div class="pk-w-sm-8">        <input class="pk-textbox"type="text"name="app_puyuetian_sms_smsbao_pass"value="{$_G['SET']['APP_PUYUETIAN_SMS_SMSBAO_PASS']}"placeholder="请填写短信宝密码">    </div></div><div class="pk-row pk-padding-bottom-15">    <label class="pk-w-sm-3 pk-padding-top-5 pk-text-bold pk-text-right pk-text-nowrap">短信宝签名</label>    <div class="pk-w-sm-8">        <input class="pk-textbox"type="text"name="app_puyuetian_sms_smsbao_sign"value="{$_G['SET']['APP_PUYUETIAN_SMS_SMSBAO_SIGN']}"placeholder="请填写短信宝签名">    </div></div><div class="pk-row pk-padding-bottom-15">    <label class="pk-w-sm-3 pk-padding-top-5 pk-text-bold pk-text-right pk-text-nowrap">每个号码每日请求短信上限</label>    <div class="pk-w-sm-8">        <input class="pk-textbox"type="text"name="app_puyuetian_sms_pnmax"value="{$_G['SET']['APP_PUYUETIAN_SMS_PNMAX']}"         placeholder="留空或0为不限制">    </div></div><div class="pk-row pk-padding-bottom-15">    <label class="pk-w-sm-3 pk-padding-top-5 pk-text-bold pk-text-right pk-text-nowrap">每个IP每日请求短信上限</label>    <div class="pk-w-sm-8">        <input class="pk-textbox"type="text"name="app_puyuetian_sms_ipmax"value="{$_G['SET']['APP_PUYUETIAN_SMS_IPMAX']}"         placeholder="留空或0为不限制">    </div></div> | 
2:打开项目:\app\hadskycloudserver\phpscript\sms_send.php 修改发送短信代码
| 
						1 
						2 
						3 
						4 
						5 
						6 
						7 
						8 
						9 
						10 
						11 
						12 
						13 
						14 
						15 
						16 
						17 
						18 
						19 
						20 
						21 
						22 
						23 
						24 
						25 
						26 
						27 
						28 
						29 
						30 
						31 
						32 
						33 
						34 
						35 
						36 
						37 
						38 
						39 
						40 
						41 
						42 
						43 
						44 
						45 
						46 
						47 
						48 
						49 
						50 
						51 
						52 
						53 
						54 
						55 
						56 
						57 
						58 
						59 
						60 
						61 
						62 
						63 
						64 
						65 
						66 
						67 
						68 
						69 
						70 
						71 
						72 
						73 
						74 
						75 | //验证是否等待了60秒if($_COOKIE['APP_PUYUETIAN_SMS_TIME']) {    exit(json_encode(array('state'=> 'no', 'msg'=> '请等待60秒后再操作')));}//验证码保护if($_G['SET']['APP_PUYUETIAN_SMS_VERIFYCODE']) {    if(!$_G['GET']['VERIFYCODE'] || $_G['GET']['VERIFYCODE'] != $_SESSION['APP_VERIFYCODE_SMS']) {        $_SESSION['APP_VERIFYCODE_SMS'] = '';        exit(json_encode(array('state'=> 'no', 'msg'=> '验证码错误')));    }    $_SESSION['APP_VERIFYCODE_SMS'] = '';}//验证该IP是否超出了今日最大请求数if(Cnum($_G['SET']['APP_PUYUETIAN_SMS_IPMAX'])) {    $rt = $_G['TABLE']['APP_PUYUETIAN_SMS_RECORD'] -> getCount(array('ip'=> getClientInfos('ip'), 'date'=> date('Ymd')));    if($rt >= $_G['SET']['APP_PUYUETIAN_SMS_IPMAX']) {        exit(json_encode(array('state'=> 'no', 'msg'=> '该IP今日请求已达上限')));    }}//接收的手机号$phonenumber = Cstr($_GET['phonenumber'], FALSE, $_G['STRING']['NUMERICAL'], 11, 11);if(substr($phonenumber, 0, 1) != 1 || !$phonenumber) {    exit(json_encode(array('state'=> 'no', 'msg'=> '手机号不正确')));}//验证该手机号是否超出了今日最大请求数if(Cnum($_G['SET']['APP_PUYUETIAN_SMS_PNMAX'])) {    $rt = $_G['TABLE']['APP_PUYUETIAN_SMS_RECORD'] -> getCount(array('pn'=> $phonenumber, 'date'=> date('Ymd')));    if($rt >= $_G['SET']['APP_PUYUETIAN_SMS_PNMAX']) {        exit(json_encode(array('state'=> 'no', 'msg'=> '该号码今日请求已达上限')));    }}//创建短信验证码if(!Cnum($_SESSION['APP_PUYUETIAN_SMS_CODE']) || !Cstr($_SESSION['APP_PUYUETIAN_SMS_PHONE'], FALSE, $_G['STRING']['NUMERICAL'], 11, 11) || $phonenumber != $_SESSION['APP_PUYUETIAN_SMS_PHONE']) {    $_SESSION['APP_PUYUETIAN_SMS_CODE'] = $code = rand(1000, 9999);    $_SESSION['APP_PUYUETIAN_SMS_PHONE'] = $phonenumber;} else{    $code = $_SESSION['APP_PUYUETIAN_SMS_CODE'];}//请求发送短信if(!empty($_G['SET']['APP_PUYUETIAN_SMS_SMSBAO_USER']) && !empty($_G['SET']['APP_PUYUETIAN_SMS_SMSBAO_PASS']) && !empty($_G['SET']['APP_PUYUETIAN_SMS_SMSBAO_SIGN'])) {    $content = '【'.$_G['SET']['APP_PUYUETIAN_SMS_SMSBAO_SIGN'].'】 您的验证码为:'.$code.',请妥善保存。';    $url = 'http://api.smsbao.com/sms?u='.$_G['SET']['APP_PUYUETIAN_SMS_SMSBAO_USER'].'&p='.md5($_G['SET']['APP_PUYUETIAN_SMS_SMSBAO_PASS']).'&m='.$phonenumber.'&c='.$content;    $ret = file_get_contents($url);    if($ret == 0) {        $r['state'] = 'ok';    }else{        $r['state'] = $ret;    }}else{$_apiurl = "http://www.hadsky.com/index.php?c=app&a=zhanzhang:index3&s=sendsms&domain={$_G['SYSTEM']['DOMAIN']}&code={$code}&phonenumber={$phonenumber}&sitekey=". md5($_G['SET']['APP_HADSKYCLOUDSERVER_SITEKEY'] . $_G['SYSTEM']['DOMAIN']);$r = json_decode(GetPostData($_apiurl, '', 10), TRUE);//$r = json_decode(file_get_contents($_apiurl));}if($r['state'] == 'ok') {    $r = array('state'=> 'ok', 'msg'=> '发送成功');    setcookie('APP_PUYUETIAN_SMS_TIME', TRUE, time() + 60);} else{    $r = array('state'=> 'no', 'msg'=> $r['datas']['msg']);} | 
好了经过以上的添加,短信宝hadsky_v7.5.0系统增加手机验证就已经安装成功,可以正常使用了
报备一下短信宝的VIP模板,这样就可以走短信宝的优质通道了,即便遇到敏感文字我们都不会人工审核,短信内容3~5秒就可送达。
另外:我们已经开发好完整的hadsky_v7.5.0系统短信宝插件,点击此链接 下载及查看安装流程。
最新更新
电商类
CMS类
微信类