外賣人是一款基于PHP+MYSQL開發的一套外賣訂餐系統,是外賣行業的佼佼者,能為外賣行業創業者搭建本地外賣平臺提供完整系統解決方案+完善的售后服務。小編今天就以替換短信接口為例帶大家進行二次開發,我們使用的短信接口是我們短信寶短信群發平臺的短信接口,我們短信寶短信群發平臺非常穩定,發送速度快,注冊就送測試短信,推薦大家使用。
1:打開項目:\templates\adminpage\other\smsset.html 修改代碼大約在 45行左右 增加短信寶頁面
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
<tr onmouseover= "this.bgColor='#F5F5F5';" onmouseout= "this.bgColor='ffffff';" bgcolor= "#ffffff" > <td class= "left" width= "20%" >選擇短信發送類型</td> <td> <select name= "smstype" id= "smstype" onchange= "doinfo();" > <option value= "2" <{ if $smstype == 2}>selected<{/ if }> >短信寶短信接口</option> <option value= "1" <{ if $smstype == 1}>selected<{/ if }> >阿里大于短信接口</option> </select> 注:若網站未對接阿里大于短信服務,請不要選擇阿里大于短信接口 </td> </tr> <tr onmouseover= "this.bgColor='#F5F5F5';" onmouseout= "this.bgColor='ffffff';" bgcolor= "#ffffff" > <td class= "left" >短信寶簽名</td> <td><input type= "text" name= "msgqianming" id= "msgqianming" value= "<{$msgqianming}>" class= "skey" style= "width:100px;" /> 注:簽名中不能含【】</td> </tr> <tr class= 'wmr' onmouseover= "this.bgColor='#F5F5F5';" onmouseout= "this.bgColor='ffffff';" bgcolor= "#ffffff" > <td class= "left" >短信寶賬號</td> <td><input type= "text" name= "sms86ac" id= "sms86ac" value= "<{$sms86ac}>" class= "skey" style= "width:250px;" > </td> </tr> <tr class= 'wmr' onmouseover= "this.bgColor='#F5F5F5';" onmouseout= "this.bgColor='ffffff';" bgcolor= "#ffffff" > <td class= "left" >短信寶密碼</td> <td><input type= "password" name= "sms86pd" id= "sms86pd" value= "<{$sms86pd}>" class= "skey" style= "width:250px;" ></td> </tr> |
2:打開項目:\class\phonecode.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
public function sendother($msg){ $contents = '【' .$ this ->qianming. '】' .$msg; $url = 'http://api.smsbao.com/sms?u=' .Mysite::$app->config[ 'sms86ac' ]. '&p=' .md5(Mysite::$app->config[ 'sms86pd' ]). '&m=' .$ this ->phone. '&c=' .urlencode($contents); logwrite( '短信發送鏈接:' .$url); $contentcccc = file_get_contents($url); logwrite( '短信發送結果:' .$contentcccc); } public function sendcode(){ if (!IValidate::suremobi($ this ->phone)){ $ this ->errId = '手機號格式錯誤' ; return false ; } if (!in_array($ this ->sendtype,$ this ->typearray)){ $ this ->errId = '未定義的發送類型' ; return false ; } if ($ this ->sendtype == 2){ $checkmember = $ this ->mysql->select_one( "select * from " .Mysite::$app->config[ 'tablepre' ]. "member where phone ='" .$ this ->phone. "' order by uid desc limit 0,1" ); if (empty($checkmember)){ $ this ->errId = '手機號對應用戶不存在' ; return false ; } }elseif($ this ->sendtype == 3){ $checkmember = $ this ->mysql->select_one( "select * from " .Mysite::$app->config[ 'tablepre' ]. "member where phone ='" .$ this ->phone. "' order by uid desc limit 0,1" ); if (empty($checkmember)){ $ this ->errId = '手機號對應用戶不存在' ; return false ; } }elseif($ this ->sendtype == 4){ }elseif($ this ->sendtype == 5){ $checkmember = $ this ->mysql->select_one( "select * from " .Mysite::$app->config[ 'tablepre' ]. "member where phone ='" .$ this ->phone. "' order by uid desc limit 0,1" ); if (empty($checkmember)){ $ this ->errId = '手機號對應用戶不存在' ; return false ; } }elseif($ this ->sendtype == 0){ $checkmember = $ this ->mysql->select_one( "select * from " .Mysite::$app->config[ 'tablepre' ]. "member where phone ='" .$ this ->phone. "' order by uid desc limit 0,1" ); if (!empty($checkmember)){ $ this ->errId = '手機號對應用戶已存在' ; return false ; } }elseif($ this ->sendtype == 8 && $ this ->sure != 1){ /*$checkmember = $this->mysql->select_one("select * from ".Mysite::$app->config['tablepre']."member where phone ='".$this->phone."' order by uid desc limit 0,1"); if(!empty($checkmember)){ $this->errId = '手機號對應用戶已存在'; return false; } */ } $checkphone = $ this ->mysql->select_one( "select * from " .Mysite::$app->config[ 'tablepre' ]. "mobileapp where phone ='" .$ this ->phone. "' and type='" .$ this ->sendtype. "' order by addtime desc limit 0,1" ); if (!empty($checkphone)){ //$checktime = time()-$this->limittime; if ($checkphone[ 'addtime' ] > time()){ // $this->errId = '驗證碼還未失效'; $ this ->code = $checkphone[ 'code' ]; $ this ->timelong = $checkphone[ 'addtime' ] - time(); return true ; } } $mintime = strtotime(date( 'Y-m-d' ,time())); $checkcounts = $ this ->mysql->counts( "select id from " .Mysite::$app->config[ 'tablepre' ]. "mobileapp where phone ='" .$ this ->phone. "' and type='" .$ this ->sendtype. "' and addtime > " .$mintime. " " ); if ($checkcounts > 3){ $ this ->errId = '每個手機號每天發送同類型驗證碼不能超過3次' ; return false ; } $ this ->code = rand(1000,9999); $data[ 'phone' ] = $ this ->phone; $data[ 'addtime' ] = time()+$ this ->limittime; $data[ 'code' ] = $ this ->code; $data[ 'type' ] = $ this ->sendtype; $ this ->mysql->insert(Mysite::$app->config[ 'tablepre' ]. 'mobileapp' ,$data); if (Mysite::$app->config[ 'smstype' ] == 1){ $smsParams = array( 'code' =>(string)$ this ->code, ); $ this ->timelong = $ this ->limittime; $aliCls= new alidayuClass(); $resp=$aliCls->sendTextMessage($ this ->aliqianming, $smsParams, $ this ->phone, $ this ->aliarr[$ this ->sendtype]); if ( $resp->Code == 'OK' ){ logwrite( '發送成功:' .$ this ->phone. ":" .$ this ->maincontent[$ this ->sendtype].$ this ->code); } else { logwrite( '大于錯誤信息:' .$resp->Message. '錯誤CODE:' .$resp->Code); } } else { $contents = '【' .$ this ->qianming. '】' .$ this ->maincontent[$ this ->sendtype].$ this ->code; $url = 'http://api.smsbao.com/sms?u=' .Mysite::$app->config[ 'sms86ac' ]. '&p=' .md5(Mysite::$app->config[ 'sms86pd' ]). '&m=' .$ this ->phone. '&c=' .urlencode($contents); $contentcccc = file_get_contents($url); logwrite( '短信發送鏈接:' . $url); $ this ->timelong = $ this ->limittime; logwrite( '短信發送結果:' .$contentcccc); } ICookie::set( 'getbackphonecode' ,$ this ->code,90); return true ; } |
經過上面的替換,短信寶的短信平臺已經替換成功了,可以正常使用了。進行測試發送:
報備一下短信寶的VIP模板,這樣就可以走短信寶的優質通道了,即便遇到敏感文字我們都不會人工審核,短信內容3~5秒就可送達。
另外:我們已經開發好完整的外賣人V_9.0系統短信寶插件,點擊此鏈接 下載及查看安裝流程。
最新更新
電商類
CMS類
微信類