微擎是一款免费开源的公众平台管理系统,基于web2.0技术架构,他有很多的扩展模块,二次开发也非常方便,智慧送水是微擎应用市场针对送水管理的一套应用模块,小编对他还是了解, 今天小编就以替换短信接口为例告诉大家如何进行二次开发,我们讲解的是v1.0.7版本,使用的短信接口是我们短信宝短信群发平台的接口,我们短信宝短信群发平台非常稳定,发送速度快,注册就送测试短信,推荐大家使用。
1:打开项目:addons\lh_water\template\web\system\sms.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
|
<form class= "form-horizontal form" action= "" method= "post" enctype= "multipart/form-data" > <div class= "admin_form_main" > <div class= "fl" >短信宝账号:</div> <div class= "fr" ><input name= "appKey" type= "text" class= "input_text_default" maxlength= "60" placeholder= " " value= "{$infoArr['appKey']}" /> <a target= "_blank" t href= "http://www.smsbao.com/register.jhtml" style= "color: red;text-decoration:none;" >还没有注册账号?立即注册</a> </div> <div class= "fl" >短信宝密码:</div> <div class= "fr" ><input name= "appSecret" type= "text" class= "input_text_default" maxlength= "60" placeholder= " " value= "{$infoArr['appSecret']}" /></div> <div class= "fl" >短信宝签名:</div> <div class= "fr" ><input name= "sign" type= "text" class= "input_text_default" maxlength= "60" placeholder= " " value= "{$infoArr['sign']}" /></div> <div class= "fl" >验证码模板</div> <div class= "fr" ><input name= "templateId" type= "text" class= "input_text_default" maxlength= "60" placeholder= " " value= "{$infoArr['templateId']}" /> <span>模板示例:您的短信验证码是%d。如非本人操作,请尽快修改密码</span> </div> <div class= "fl" ></div> <div class= "fr" > <input name= "submit" type= "submit" class= "admin_submit big" id= "J_edit" value= "保存" /> <input type= "hidden" name= "token" value= "{$_W['token']}" /> </div> <div class= "clear" ></div> </div> </form> |
2:打开项目:\addons\lh_water\inc\mobile\sms.inc.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
|
<?php namespace Aliyun\DySDKLite\Sms; require_once IA_ROOT . "/addons/lh_water/common/settings.php" ; require_once IA_ROOT . "/addons/lh_water/alisms/SignatureHelper.php" ; use Aliyun\DySDKLite\SignatureHelper; $redirectUrl = $_GPC[ 'redirectUrl' ]; $type = $_GPC[ 'type' ]; $phone = $_GPC[ 'phone' ]; if (empty($phone)) { echo '手机号不能为空' ; } else { $infoArr = array(); $item = pdo_fetchall( "SELECT * FROM " .tablename( 'lh_water_setting' ). " WHERE uniacid = :uniacid and type = 'sms'" , array( ':uniacid' => $uniacid)); if (is_array($item)) { foreach ($item as $t) { $infoArr[$t[ 'key' ]] = $t[ 'value' ]; } } $appKey = $infoArr[ 'appKey' ]; $appSecret = $infoArr[ 'appSecret' ]; $sign = $infoArr[ 'sign' ]; $templateId = $infoArr[ 'templateId' ]; // 发送短信验证码 $code = rand(100000, 999999); $params = array (); $accessKeyId = $appKey; $accessKeySecret = $appSecret; $params[ "PhoneNumbers" ] = $phone; $params[ "SignName" ] = $sign; $params[ "TemplateCode" ] = $templateId; // $params['TemplateParam'] = Array ( // "code" => $code // ); // // if(!empty($params["TemplateParam"]) && is_array($params["TemplateParam"])) { // $params["TemplateParam"] = json_encode($params["TemplateParam"], JSON_UNESCAPED_UNICODE); // } $params[ 'TemplateParam' ] = sprintf($templateId,$code); $user = $appKey; //短信平台帐号 $pass = md5($appSecret); //短信平台密码 $content= '【' .$params[ "SignName" ]. '】' .$params[ 'TemplateParam' ]; //要发送的短信内容 $phone = $phone; //要发送短信的手机号码 $sendurl = $smsapi. "sms?u=" .$user. "&p=" .$pass. "&m=" .$phone. "&c=" .urlencode($content); $result =file_get_contents($sendurl) ; if ($result == '0' ){ echo 'success' ; } $_SESSION[ 'sms' . $phone] = $code; } |
经过上面的替换,短信宝的短信平台已经替换成功了,可以正常使用了。进行测试发送:
报备一下短信宝的VIP模板,这样就可以走短信宝的优质通道了,即便遇到敏感文字我们都不会人工审核,短信内容3~5秒就可送达。
另外:我们已经开发好完整的智慧送水v1.0.7系统短信宝插件,点击此链接 下载及查看安装流程。
最新更新
电商类
CMS类
微信类