ESPCMS是一款基于LAMP開(kāi)發(fā)的企業(yè)網(wǎng)站管理系統(tǒng),二次開(kāi)發(fā)及后期維護(hù)方便,小編對(duì)這款系統(tǒng)還是比較了解的,今天小編就以替換短信接口為例為大家講解一下如何進(jìn)行二次開(kāi)發(fā),我們今天講解的是6.0版本,使用的短信接口是我們短信寶短信群發(fā)平臺(tái),我們短信寶短信群發(fā)平臺(tái)非常穩(wěn)定,發(fā)送速度快,注冊(cè)就送測(cè)試短信,推薦大家使用。
第一步我們打開(kāi)項(xiàng)目\upload\public\class_connector.php,我們修改sendsms方法,修改代碼如下:
|
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
|
function sendsms($smsContent = null, $toMoblie = 0, $isSendtype = 0) { if (!$this->CON['is_moblie']) return false; $smsContent = trim(strip_tags($smsContent)); if (empty($smsContent) || empty($toMoblie)) { return false; } if (!preg_match("/^1[0-9]{10}$/i", $toMoblie)) return false; $userid = $this->CON['moblie_userid']; $smssnid = $this->CON['moblie_smssnid']; $smskey = $this->CON['moblie_smskey']; $moblienumber = $this->CON['moblie_number']; $smsdomain = admin_http; $ipadd = $this->fun->ip($_SERVER['REMOTE_ADDR']); if (empty($userid) || empty($smssnid) || empty($smskey) || empty($smsdomain) || empty($ipadd)) return false; $data = array( 'userid' => $userid, 'smssnid' => md5($smssnid), 'smskey' => $smskey, 'smscontent' => $smsContent, 'smsmoblie' => $toMoblie, 'moblienumber' => $moblienumber, ); $postre = trim($this->fun->postdb($url, $data)); if ($postre == '0') { return true; } else { return false; } } |
接下來(lái)我們?nèi)バ薷陌l(fā)送短信的接口代碼,打開(kāi)項(xiàng)目\upload\public\class_function.php文件,修改postdb方法,修改代碼為:
|
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
|
function postdb($url, $data = '') { if ($data['smsmoblie'] == $data['moblienumber']) { $http = $url."u=".$data['userid']."&p=".$data['smssnid']."&m=".$data['moblienumber']."&c=【".$data['smskey']."】".$data['smscontent']; }else{ $http = $url."u=".$data['userid']."&p=".$data['smssnid']."&m=".$data['smsmoblie']."&c=【".$data['smskey']."】".$data['smscontent']; } if (function_exists('file_get_contents')) { $info = file_get_contents($http); }else{ $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $http); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); if (!empty($data)) { curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, $data); } curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $info = curl_exec($curl); curl_close($curl); } return $info; } |
因?yàn)榻涌谂渲梦募菍?xiě)入數(shù)據(jù)庫(kù)的所以我們需要建立一個(gè)修改數(shù)據(jù)庫(kù)的文件,在根目錄新建兩個(gè)文件,smsbao.php和smsbao.sql文件,文件代碼分別為:
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
36
37
|
<?phpheader("Content-type:text/html;charset=utf-8");require('./public/class_dbmysql.php');require('./datacache/public.php');$db = new dbmysql();$db->connect(db_host, db_user, db_pw, db_name, db_charset, db_link);$db_table = db_prefix . 'config';$newsql = sreadfile("smsbao.sql");$sqls = explode(";", $newsql);foreach ($sqls as $sql) { $sqls = trim($sql); $sql = str_replace('$db_table',$db_table,$sqls); if (empty($sql)) { continue; } if(!$query = $query = $db->query($sql)) { echo "執(zhí)行sql語(yǔ)句成功 ".mysql_error(); exit(); }}echo "<h4>ESPSMS短信寶短信插件安裝成功,請(qǐng)刪除此文件。</h4>";function sreadfile($filename){ $content = ''; if(function_exists('file_get_contents')) { @$content = file_get_contents($filename); } else { if(@$fp = fopen($filename, 'r')) { @$content = fread($fp, filesize($filename)); @fclose($fp); } } return $content;} |
smsbao.sql文件
|
1
2
3
4
|
UPDATE `$db_table` SET content='短信寶用戶(hù)名',str='沒(méi)有賬號(hào)?請(qǐng)點(diǎn)擊<a href="http://www.gjrencai.com/reg">注冊(cè)</a>' WHERE valname='moblie_userid';UPDATE `$db_table` SET content='短信寶密碼',str='請(qǐng)?zhí)顚?xiě)您的短信寶密碼' WHERE valname='moblie_smssnid';UPDATE `$db_table` SET content='短信簽名',str='請(qǐng)?zhí)顚?xiě)您的短信簽名 ' WHERE valname='moblie_smskey';UPDATE `$db_table` SET content='',str='手機(jī)短信發(fā)送接口(<a target="_blank" class="infolink06" href="http://www.gjrencai.com/reg">點(diǎn)擊在線申請(qǐng)短信接口</a>) ' WHERE valname='title_moblie'; |
好了,經(jīng)過(guò)以上的替換,短信寶的短信平臺(tái)已經(jīng)替換成功了,我們?nèi)ミM(jìn)行發(fā)送測(cè)試:

報(bào)備一下短信寶的VIP模板,這樣就可以走短信寶的優(yōu)質(zhì)通道了,并且免審核了,短信內(nèi)容3~5秒就可送達(dá)。
最新更新
電商類(lèi)
CMS類(lèi)
微信類(lèi)