外卖人是一款基于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类
微信类