彩虹易支付系统,专注于聚合支付网站解决方案提供。小编对这款系统还比较了解,今天就以替换短信接口为例为大家讲解一下如何进行二次开发,使用的短信接口是我们短信宝短信群发平头的短信接口,我们短信宝短信群发平台非常稳定,发送速度快,注册就送测试短信,推荐大家使用
1:打开项目:admin\set.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
|
<form onsubmit= "return saveSetting(this)" method= "post" class= "form-horizontal" role= "form" > <div class= "form-group" > <label class= "col-sm-2 control-label" >接口选择</label> <div class= "col-sm-10" ><select class= "form-control" name= "sms_api" default = "<?php echo $conf['sms_api']?>" ><option value= "0" >企信通短信接口</option><option value= "1" >腾讯云短信接口</option><option value= "2" >阿里云短信接口</option><option value= "3" >ThinkAPI短信接口</option><option value= "4" >短信宝短信接口</option></select></div> </div><br/> <div class= "form-group" id= "showAppId" style= "<?php echo $conf['sms_api']==0||$conf['sms_api']==3?'display:none;':null; ?>" > <label class= "col-sm-2 control-label" >AppId</label> <div class= "col-sm-10" ><input type= "text" name= "sms_appid" value= "<?php echo $conf['sms_appid']; ?>" class= "form-control" /></div> </div><br/> <div class= "form-group" > <label class= "col-sm-2 control-label" >AppKey</label> <div class= "col-sm-10" ><input type= "password" name= "sms_appkey" value= "<?php echo $conf['sms_appkey']; ?>" class= "form-control" /></div> </div><br/> <div class= "form-group" id= "showSign" style= "<?php echo $conf['sms_api']==0?'display:none;':null; ?>" > <label class= "col-sm-2 control-label" >短信签名内容</label> <div class= "col-sm-10" ><input type= "text" name= "sms_sign" value= "<?php echo $conf['sms_sign']; ?>" class= "form-control" /><font color= "green" >必须是已添加、并通过审核的短信签名。</font></div> </div><br/> <div class= "form-group" > <label class= "col-sm-2 control-label" >商户注册模板</label> <div class= "col-sm-10" ><input type= "text" name= "sms_tpl_reg" value= "<?php echo $conf['sms_tpl_reg']; ?>" class= "form-control" /></div> </div><br/> <div class= "form-group" > <label class= "col-sm-2 control-label" >找回密码模板</label> <div class= "col-sm-10" ><input type= "text" name= "sms_tpl_find" value= "<?php echo $conf['sms_tpl_find']; ?>" class= "form-control" /></div> </div><br/> <div class= "form-group" > <label class= "col-sm-2 control-label" >修改结算账号模板</label> <div class= "col-sm-10" ><input type= "text" name= "sms_tpl_edit" value= "<?php echo $conf['sms_tpl_edit']; ?>" class= "form-control" /></div> </div><br/> <div class= "form-group" > <div class= "col-sm-offset-2 col-sm-10" ><input type= "submit" name= "submit" value= "修改" class= "btn btn-primary form-control" /><br/> </div><br/> </div> </form> |
2:打开项目:includes\lib\sms 新增SmsBao.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
|
<?php namespace lib\sms; class SmsBao { private $AccessKeyId; private $AccessKeySecret; function __construct($AccessKeyId, $AccessKeySecret){ $ this ->AccessKeyId = $AccessKeyId; $ this ->AccessKeySecret = $AccessKeySecret; } public function send($phone, $code, $moban, $sign, $sitename){ if (empty($ this ->AccessKeyId)||empty($ this ->AccessKeySecret)) return false ; $statusStr = array( "0" => "短信发送成功" , "-1" => "参数不全" , "-2" => "服务器空间不支持,请确认支持curl或者fsocket,联系您的空间商解决或者更换空间!" , "30" => "密码错误" , "40" => "账号不存在" , "41" => "余额不足" , "42" => "帐户已过期" , "43" => "IP地址限制" , "50" => "内容含有敏感词" ); $content = '【' .$sign. '】' .str_replace( '{$code}' ,$code,$moban); $user = $ this ->AccessKeyId; //短信平台帐号 $pass = md5($ this ->AccessKeySecret); //短信平台密码 $sendurl = $smsapi. "sms?u=" .$user. "&p=" .$pass. "&m=" .$phone. "&c=" .urlencode($content); $result =file_get_contents($sendurl) ; if ($result == 0){ return [ 'Code' => 'OK' , 'Message' => 'success' ]; } return [ 'Message' =>$statusStr[$result]]; } } |
3:打开项目:includes\functions.php 修改短信发生方法send
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
|
<?php namespace lib\sms; class SmsBao { private $AccessKeyId; private $AccessKeySecret; function __construct($AccessKeyId, $AccessKeySecret){ $ this ->AccessKeyId = $AccessKeyId; $ this ->AccessKeySecret = $AccessKeySecret; } public function send($phone, $code, $moban, $sign, $sitename){ if (empty($ this ->AccessKeyId)||empty($ this ->AccessKeySecret)) return false ; $statusStr = array( "0" => "短信发送成功" , "-1" => "参数不全" , "-2" => "服务器空间不支持,请确认支持curl或者fsocket,联系您的空间商解决或者更换空间!" , "30" => "密码错误" , "40" => "账号不存在" , "41" => "余额不足" , "42" => "帐户已过期" , "43" => "IP地址限制" , "50" => "内容含有敏感词" ); $content = '【' .$sign. '】' .str_replace( '{$code}' ,$code,$moban); $user = $ this ->AccessKeyId; //短信平台帐号 $pass = md5($ this ->AccessKeySecret); //短信平台密码 $sendurl = $smsapi. "sms?u=" .$user. "&p=" .$pass. "&m=" .$phone. "&c=" .urlencode($content); $result =file_get_contents($sendurl) ; if ($result == 0){ return [ 'Code' => 'OK' , 'Message' => 'success' ]; } return [ 'Message' =>$statusStr[$result]]; } } |
好了,经过以上的替换,短信宝的短信平台已经替换成功了,可以正常使用了。我们进行测试发送。
报备一下短信宝的VIP模板,这样就可以走短信宝的优质通道了,即便遇到敏感文字我们都不会人工审核,短信内容3~5秒就可送达。
另外:我们已经开发好完整的彩虹易支付2022.3.3系统短信宝插件,点击此链接 下载及查看安装流程。
最新更新
电商类
CMS类
微信类