91成人在线播放_欧美一区二区视频在线观看_91精品国产高清久久久久久_国产精品久久亚洲不卡4k岛国


待發(fā)短信

在線客服
產(chǎn)品支持 短信寶客服
合作渠道 渠道合作
服務(wù)咨詢

4001-021-502

工作時(shí)間

9:00-21:00

WhatsnsV4問(wèn)答系統(tǒng)新增短信寶短信接口

WhatsnsV4問(wèn)答系統(tǒng)是一款可以根據(jù)自身業(yè)務(wù)需求快速搭建垂直化領(lǐng)域的php開(kāi)源問(wèn)答系統(tǒng),內(nèi)置上百個(gè)功能幫助站長(zhǎng)一分鐘完成PC、Wap、微信端、小程序、APP問(wèn)答應(yīng)用建設(shè)。小編對(duì)他還是比較了解的,今天小編就以新增短信接口為例,給大家講解一下如何進(jìn)行二次開(kāi)發(fā),我們今天講解的是V4版本,使用的短信接口是我們短信寶短信群發(fā)平臺(tái)的短信接口,我們短信寶短信群發(fā)平臺(tái)的接口非常穩(wěn)定,發(fā)送速度快,注冊(cè)就送測(cè)試短信,推薦大家使用。

首先打開(kāi)項(xiàng)目:\system\helpers\public_helper.php 增加下短信發(fā)送方法

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
function smsbao($user,$phone,$key,$sing,$code){
    $message [] = array ();
    $smsapi "http://api.smsbao.com/";
    $user $user//短信平臺(tái)帳號(hào)
    $pass = md5($key); //短信平臺(tái)密碼
    $content '您的注冊(cè)驗(yàn)證碼是'.$code.'請(qǐng)不要把驗(yàn)證碼泄露給其他人。若非本人操作,可不用理會(huì)。';
    $content='【'.$sing.'】'.$content;//要發(fā)送的短信內(nèi)容
    $phone $phone;//要發(fā)送短信的手機(jī)號(hào)碼
    $sendurl $smsapi."sms?u=".$user."&p=".$pass."&m=".$phone."&c=".urlencode($content);
    $result =file_get_contents($sendurl) ;
    if ($result == 0){
        $message ['errorcode'] = 0;
        // 狀態(tài)為0,說(shuō)明短信發(fā)送成功
        $message ['msg'] = '短信發(fā)送成功';
    }else{
        $message ['errorcode'] = 1;
        $message ['msg'] = '短信發(fā)送失敗';
    }
    return $message;
}

打開(kāi)項(xiàng)目:\application\views\default\register.php 修改下代碼

?
1
2
3
4
5
 <div class="input-prepend  no-radius security-up-code js-security-number ">
        <input type="text" id="seccode_verify" name="seccode_verify"  placeholder="手機(jī)驗(yàn)證碼" onblur="check_phone();">
      <i class="fa fa-get-pocket"></i>
      <a  id="testbtn" onclick="gosms()" class="btn-up-resend js-send-code-button" href="javascript:;">發(fā)送驗(yàn)證碼</a>
      <div>

打開(kāi)項(xiàng)目:\application\views\admin\setting_sms.php 增加短信發(fā)送模板

?
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
<!--{template header}-->
<div style="width:100%; height:15px;color:#000;margin:0px 0px 10px;">
  <div style="float:left;"><a href="index.php?admin_main/stat{$setting['seo_suffix']}" target="main"><b>控制面板首頁(yè)</b></a>&nbsp;&raquo;&nbsp;短信設(shè)置</div>
</div>
<!--{if isset($message)}-->
<!--{eval $type=isset($type)?$type:'correctmsg'; }-->
<div class="alert  alert-warning">{$message}</div>
<!--{/if}-->
        <form action="index.php?admin_setting/sms{$setting['seo_suffix']}" method="post">
            <table class="table">
                <tr class="header">
                    <td colspan="2">短信參數(shù)設(shè)置</td>
                </tr>
                <tr>
                    <td class="altbg1" width="45%"><b>短信寶賬號(hào):</b><br><span class="smalltxt"></span></td>
                    <td class="altbg2"><input class="form-control shortinput" type="text" value="{if isset($setting['smsid'])}$setting['smsid']{/if}" name="smsid" /></td>
                    <td class="altbg3">還沒(méi)有注冊(cè)賬號(hào)?<a target="_blank" style="color: red;" href="http://www.gjrencai.com/register.jhtml">立即注冊(cè)</a></td>
 
 
                </tr>
                <tr>
                    <td class="altbg1" width="45%"><b>短信寶密碼:</b><br><span class="smalltxt"></span></td>
                    <td class="altbg2"><input class="form-control shortinput" type="text" value="{if isset($setting['smskey'])}$setting['smskey']{/if}" name="smskey" /></td>
                </tr>
                <tr>
                    <td class="altbg1" width="45%"><b>短信寶簽名:</b><br><span class="smalltxt"></span></td>
                    <td class="altbg2"><input class="form-control shortinput" type="text" value="{if isset($setting['smssing'])}$setting['smssing']{/if}" name="smssing" /></td>
                </tr>
 
 
                <tbody >
                <tr>
                    <td class="altbg1" width="45%"><b>是否啟用短信驗(yàn)證碼注冊(cè):</b><br><span class="smalltxt">開(kāi)啟后沒(méi)有手機(jī)注冊(cè)的用戶登錄后會(huì)提示驗(yàn)證手機(jī)號(hào),同時(shí)注冊(cè)入口取消圖形驗(yàn)證碼啟用短信驗(yàn)證碼</span></td>
                    <td class="altbg2"><input type="checkbox" class=" " {if isset($setting['smscanuse'])&&$setting['smscanuse']==1} checked {/if} name="smscanuse">啟用手機(jī)驗(yàn)證碼</td>
                </tr
                </tbody>
            </table>
            <br />
            <center><input type="submit" class="btn btn-success" name="submit" value="提 交"></center><br>
        </form>
<br />
<style>
html,body{
    overflow:scroll;
}
</style>
<!--{template footer}-->

打開(kāi)項(xiàng)目:\application\views\admin\public_menu.php 增加行下代碼

?
1
  <li><a href="{SITE_URL}index.php?admin_setting/sms{$setting['seo_suffix']}" target="main"><i class="fa fa-genderless text-success"></i>短信設(shè)置</a> </li>

打開(kāi)項(xiàng)目:\application\controllers\Admin\Admin_setting.php 增加行短信設(shè)置

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
    /* 短信設(shè)置 */
    function sms() {
        if (null!== $this->input->post ('submit')) {
            checkattack($_POST'post');
            foreach $_POST as $key => $value ) {
                if ('sms' == substr $key, 0, 3 )) {
                    $this->setting [$key] = $value;
                }
            }
            if ($this->input->post ('smscanuse') == 'on') {
                $this->setting ['smscanuse'] = 1;
            else {
                $this->setting ['smscanuse'] = 0;
            }
            $this->setting_model->update ( $this->setting );
            $message '短信設(shè)置更新成功!';
        }
       

打開(kāi)項(xiàng)目:\application\controllers\User.php 修改下發(fā)送類

?
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
    function getsmscode() {
        // $startime=tcookie('smstime');
        // $timespan=time()-$startime;
        // echo $timespan;exit();
        if ($this->setting ['smscanuse'] == 0) {
            echo '0';
            exit ();
        }
        $phone $this->input->post ( 'phone' );
        if (! preg_match ( "/^1[34578]{1}\d{9}$/"$phone )) {
            
            exit "3" );
        }
        if ($_POST ['type'] && $_POST ['type'] == 'reg') {
            $userone $this->user_model->get_by_phone ( $phone );
            if ($userone != null) {
                exit '2' );
            }
        }
        
        // $userone=$_ENV['user']->get_by_phone($phone);
        // if($userone!=null){
        // exit("2");
        // }
        session_start ();
        if ($_SESSION ["time"] != null) {
            $startime $_SESSION ['time'];
            
            $timespan = time () - $startime;
            
            if ($timespan < 60) {
                
                echo '0';
                exit ();
            else {
                $phone $this->input->post ( 'phone' );
                $_SESSION ["time"] = null;
                $_SESSION ["time"] = time ();
                $code = random ( 4, 1 );
                $this->user_model->save_code ( strtolower $code ) );
//              $codenum = $this->setting ['smstmpvalue'];
//              $codenum = str_replace ( '{code}', $code, $codenum );
                $msg = smsbao ( $this->setting ['smsid'], $phone$this->setting ['smskey'],$this->setting ['smssing'], $code );
                exit '1' );
            }
        else {
            // $phone=$this->post['phone'];
            // $userone=$_ENV['user']->get_by_phone($phone);
            // if($userone!=null){
            // exit("2");
            // }
            
            $code = random ( 4, 1 );
            $this->user_model->save_code ( strtolower $code ) );
//          $codenum = $this->setting ['smstmpvalue'];
//          $codenum = str_replace ( '{code}', $code, $codenum );
            $msg = smsbao ( $this->setting ['smsid'], $phone$this->setting ['smskey'],$this->setting ['smssing'], $code );
            $_SESSION ["time"] = time ();
            exit '1' );
        }
        
        echo $timespan;
        exit ();
    }

經(jīng)過(guò)上面的替換,短信寶的短信平臺(tái)已經(jīng)替換成功了,可以正常使用了。

 

報(bào)備一下短信寶的VIP模板,這樣就可以走短信寶的優(yōu)質(zhì)通道了,即便遇到敏感文字我們都不會(huì)人工審核,短信內(nèi)容3~5秒就可送達(dá)。

另外:我們已經(jīng)開(kāi)發(fā)好完整的WhatsnsV4問(wèn)答系統(tǒng)短信寶插件,點(diǎn)擊此鏈接 下載及查看安裝流程。

開(kāi)源插件

最新更新

電商類

CMS類

微信類

文章標(biāo)簽