微擎是一款免費開源的公眾平臺管理系統,基于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.gjrencai.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類
微信類