大米CMS(又名3gcms)是一個免費開源、快速、簡單的PC建站和手機建站集成一體化系統, 致力于為用戶提供簡單、快捷的PC建站和智能手機建站解決方案。小編對他還是比較了解的,今天小編就以新增短信接口為例,給大家講解一下如何進行二次開發,我們今天講解的是V6版本,使用的短信接口是我們短信寶短信群發平臺的短信接口,我們短信寶短信群發平臺的接口非常穩定,發送速度快,注冊就送測試短信,推薦大家使用。
首先打開項目:\Admin\Tpl\default\Config\index.html 在38行增加下代碼
|
1
2
3
4
5
6
7
8
9
|
<ul class="nav nav-tabs"> <li style="width:100px;"><a data-toggle="tab"></a></li> <li class="active"><a href="#total_config" data-toggle="tab">網站整體配置</a></li> <li><a href="#home_config" data-toggle="tab">首頁配置</a></li> <li><a href="#list_config" data-toggle="tab">列表頁配置</a></li> <li><a href="#content_config" data-toggle="tab">內容頁配置</a></li> <li><a href="#mail_config" data-toggle="tab">郵件發送配置</a></li> <li><a href="#sms_config" data-toggle="tab">短信發送配置</a></li> </ul> |
同時增加下短信配置
|
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
|
<div class="tab-pane" id="sms_config"> <div id="myTab1_Content3" style="clear:both;"> <table width="100%" border="0" align=center cellpadding="3" cellspacing="1" style="margin:5px 0;background:#FFF"> <tr onMouseOver="this.style.backgroundColor='#EEFCDD';this.style.color='red'" onMouseOut="this.style.backgroundColor='';this.style.color=''"> <td width="40%" align="right">短信寶賬號: </td> <td align="center"> </td> <td width="60%" align="left"> <input name="SMS_FROM" type="text" id="MAIL_FROM" onFocus="hSiteTitle.style.color='blue';" onBlur="hSiteTitle.style.color='#ccc';" value="" style="width:300px;"> 還沒有注冊短信寶賬號?<a href="HTTP://www.gjrencai.com/register.jhtml" target="_blank" style="color: red;">立即注冊</a> </td> </tr> <tr onMouseOver="this.style.backgroundColor='#EEFCDD';this.style.color='red'" onMouseOut="this.style.backgroundColor='';this.style.color=''"> <td width="40%" align="right">短信寶密碼: </td> <td align="center"> </td> <td width="60%" align="left"><input name="SMS_PASSSWORD" type="password" id="MAIL_PASSSWORD" onFocus="hSiteTitle.style.color='blue';" onBlur="hSiteTitle.style.color='#ccc';" value="" style="width:300px;"></td> </tr> <tr onMouseOver="this.style.backgroundColor='#EEFCDD';this.style.color='red'" onMouseOut="this.style.backgroundColor='';this.style.color=''"> <td width="40%" align="right">短信寶簽名: </td> <td align="center"> </td> <td width="60%" align="left"><input name="SMS_SING" type="text" id="MAIL_PASSSWORD" onFocus="hSiteTitle.style.color='blue';" onBlur="hSiteTitle.style.color='#ccc';" value="" style="width:300px;"></td> </tr> <tr class="css_page_list"> <td height="30" colspan=3 align="center"> <input type="hidden" name="id" value="{$list.id}"/> <input name='Submit' type='submit' class="btn btn-success" value=' 保存設置 '></td> </tr> </table> </div> </div> |
打開項目:\Admin\Lib\Action\ConfigAction.class.php 新增下代碼
|
1
2
3
|
$configStr = preg_replace("/'SMS_FROM'=>'.*'/","'SMS_FROM'=>'".htmlspecialchars($_POST['SMS_FROM'],ENT_QUOTES)."'",$configStr); $configStr = preg_replace("/'SMS_SING'=>'.*'/","'SMS_SING'=>'".htmlspecialchars($_POST['SMS_SING'],ENT_QUOTES)."'",$configStr); if(C('SMS_PASSSWORD') != $_POST['SMS_PASSSWORD']){$configStr = preg_replace("/'SMS_PASSSWORD'=>'.*'/","'SMS_PASSSWORD'=>'".$_POST['SMS_PASSSWORD']."'",$configStr);} |
打開項目:\Web\Common\common.php 修改發送短信類
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
function send_smsmess($to_mobile,$content,$isvail=0){ if($isvail==1){ $config = F('basic', '', './Web/Conf/'); $mobile_code = mt_rand(1000,9999); $content = "您的驗證碼是:".$mobile_code."。請不要把驗證碼泄露給其他人。"; } $user = C('SMS_FROM'); //短信平臺帳號 $pass = md5(C('SMS_PASSSWORD')); //短信平臺密碼 $content='【'.C('SMS_SING').'】'.$content;//要發送的短信內容 $phone = $to_mobile;//要發送短信的手機號碼 $sendurl = $smsapi."sms?u=".$user."&p=".$pass."&m=".$phone."&c=".urlencode($content); $result =file_get_contents($sendurl) ; //$data = ("account=".C('SMS_FROM')."&password=".C('SMS_PWD')."&mobile=".$to_mobile."&content=".rawurlencode($content));//短信用戶名與密碼請在這里改 //密碼可以使用明文密碼或使用32位MD5加密 //$gets = xml_to_array(SPost($data, $target)); //var_dump($gets); if($result==0 && $isvail==1){ $_SESSION['mobile_verify'] = md5($mobile_code); } return $result;} |
打開項目:\Public\Config\config.ini.php開啟短信配置
|
1
|
'MOBILE_VERIFY'=>'1',//手機短信驗證碼 |
經過上面的替換,短信寶的短信平臺已經替換成功了,可以正常使用了。

報備一下短信寶的VIP模板,這樣就可以走短信寶的優質通道了,即便遇到敏感文字我們都不會人工審核,短信內容3~5秒就可送達。
另外:我們已經開發好完整的大米cms_v6系統短信寶插件,點擊此鏈接 下載及查看安裝流程。
最新更新
電商類
CMS類
微信類