微擎是一款免费开源的公众平台管理系统,基于web2.0技术架构,他有很多的扩展模块,二次开发也非常方便。超级粉丝社区是微擎应用市场中唯一支持乐视云直播和腾讯云直播的系统模块的社区系统。小编对他还是很了解,今天小编就以替换短信接口为例告诉大家如何进行二次开发,我们讲解的是V6.7版本,使用的短信接口是我们短信宝短信群发平台的接口,我们短信宝短信群发平台非常稳定,发送速度快,注册就送测试短信,推荐大家使用。
1:打开项目:addons\sunshine_huayue\template\set_alidayu.html 新增短信宝界面
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
|
<div class= "container-fluid" > <h4><span class= 'glyphicon glyphicon-circle-arrow-right' ></span> 总消息模板开关</h4> <div class= "row" > <div class= "col-md-6" > <label>开关</label> { if $ this ->settings[ 'alidayu_key' ] == 'open' } <button class= "form-control btn btn-sm btn-success" onclick= "doSave('alidayu_key','close')" >已开启短信发送</button> { else } <button class= "form-control btn btn-sm btn-danger" onclick= "doSave('alidayu_key','open')" >已关闭短信发送</button> {/ if } <p class= "help-block" >控制是否开启短信发送,开启后请务必配置好下面设置项</p> </div> </div> <br> <!-- 短信配置--> <h4><span class= 'glyphicon glyphicon-circle-arrow-right' ></span> 短信配置</h4> <div class= "row" > <div class= "col-md-6" > <label>短信宝用户名</label> <input type= "text" class= "form-control" value= "{php echo $this->settings['alidayu_ak']}" id= 'alidayu_ak' placeholder= '' > <p class= "help-block" ></p> <button class= "btn btn-sm btn-info" onclick= "doSave('alidayu_ak')" >保存</button> <br> </div> </div> <br> <div class= "row" > <div class= "col-md-6" > <label>短信宝密码</label> <input type= "text" class= "form-control" value= "{php echo $this->settings['alidayu_sk']}" id= 'alidayu_sk' placeholder= '' > <p class= "help-block" ></p> <button class= "btn btn-sm btn-info" onclick= "doSave('alidayu_sk')" >保存</button> <br> </div> </div> <br> <div class= "row" > <div class= "col-md-6" > <label>短信模板</label> <input type= "text" class= "form-control" value= "{php echo $this->settings['alidayu_tpl_id']}" id= 'alidayu_tpl_id' placeholder= '' > <p class= "help-block" >请保证短信模板中的变量为${product}和${code},其他变量将导致发送失败</p> <button class= "btn btn-sm btn-info" onclick= "doSave('alidayu_tpl_id')" >保存</button> <br> </div> </div> <br> <div class= "row" > <div class= "col-md-6" > <label>短信宝签名</label> <input type= "text" class= "form-control" value= "{php echo $this->settings['alidayu_sign_name']}" id= 'alidayu_sign_name' placeholder= '' > <p class= "help-block" ></p> <button class= "btn btn-sm btn-info" onclick= "doSave('alidayu_sign_name')" >保存</button> <br> </div> </div> <br> |
2:打开项目:addons\sunshine_huayue\Component\SmsComponent.class.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
|
<?php class SmsComponent { static function sendCaptcha($mobile,$captcha,$openid = '' ) { include dirname(dirname(__FILE__)). '/plugin/alidayu/TopSdk.php' ; $settings_product = sunshine_huayueModuleSite::$_SET[ 'alidayu_product' ]; $settings_product = $settings_product ? $settings_product : '快来租我' ; $content = str_replace([ '${product}' , '${code}' ],[ "$settings_product" , "$captcha" ],sunshine_huayueModuleSite::$_SET[ 'alidayu_tpl_id' ]); $statusStr = array( "0" => "短信发送成功" , "-1" => "参数不全" , "-2" => "服务器空间不支持,请确认支持curl或者fsocket,联系您的空间商解决或者更换空间!" , "30" => "密码错误" , "40" => "账号不存在" , "41" => "余额不足" , "42" => "帐户已过期" , "43" => "IP地址限制" , "50" => "内容含有敏感词" ); $user = sunshine_huayueModuleSite::$_SET[ 'alidayu_ak' ]; //短信平台帐号 $pass = md5(sunshine_huayueModuleSite::$_SET[ 'alidayu_sk' ]); //短信平台密码 $content= "【" .sunshine_huayueModuleSite::$_SET[ 'alidayu_sign_name' ]. "】" .$content; $phone = $mobile; //要发送短信的手机号码 $sendurl = $smsapi. "sms?u=" .$user. "&p=" .$pass. "&m=" .$phone. "&c=" .urlencode($content); $result =file_get_contents($sendurl); WeUtility::logging( 'sunshine_huayue_SmsComponent' , var_export($result, true )); if ($result == '0' ) { return true ; } else { return false ; } } } |
经过上面的替换,短信宝的短信平台已经替换成功了,可以正常使用了。进行测试发送:
报备一下短信宝的VIP模板,这样就可以走短信宝的优质通道了,即便遇到敏感文字我们都不会人工审核,短信内容3~5秒就可送达。
另外:我们已经开发好完整的超级粉丝社区V6.7系统系统短信宝插件,点击此链接 下载及查看安装流程。
最新更新
电商类
CMS类
微信类