天天團購系統(tǒng)是一套強大的開源團購程序,采用PHP+mysql開發(fā),系統(tǒng)內(nèi)置支付寶、財付通、GOOGLE地圖等接口,支持短信發(fā)送團購券和實物團購快遞發(fā)貨等;另外可通過Ucenter模塊,與網(wǎng)站已有系統(tǒng)無縫整合,實現(xiàn)用戶同步注冊、登陸、退出。今天小編就以替換短信接口為例一步一步教大家如何開發(fā),進行替換的短信接口是我們短信寶短信群發(fā)平臺的短信接口,我們短信寶短信接口非常穩(wěn)定,發(fā)送速度快,注冊還送測試短信,推薦大家使用。
首先我們打開項目\setting\service.php文件,替換51行左右的代碼:
|
1
2
3
4
5
|
'smsbao' => array ( 'name' => '短信寶通道', 'intro' => '<font color="red">【推薦】</font>速度快,價格便宜,性價比高<br>禁發(fā)營銷、抽獎類短信,包括簽名在內(nèi)單條70個字,長短信每條67字(簽名接口設(shè)置頁自行設(shè)置,推薦用站點名稱)<br/><a href="http://www.gjrencai.com/fee" target="_blank"><font color="red">點此在線購買</font></a>', ), |
替換完成之后,打開項目\templates\admin\service_sms_list.html文件,替換16行代碼:
|
1
|
{if in_array($one['flag'],array('smsbao','ums','tyx'))} |
接著打開項目\templates\admin\service_sms_mgr.html文件,替換第4行的代碼:
|
1
|
{if in_array($c['cfg']['driver'],array('smsbao','tyx'))} |
接著在項目\include\driver\service\下創(chuàng)建sms.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
<?phpclass smsbao_smsServiceDriver extends smsServiceDriver{private $cfg = array();public function config($cfg){$this->cfg = $cfg;}public function IMSend($phone,$content){if (false != $exids = $this->BC_EXPS($phone,$content,$this->cfg['bcmax'])){return '@exps('.count($exids).')';}if ($this->cfg['sign']) {$smsb = $sms = $content.'【'.$this->cfg['sign'].'】';}else{$smsb = $sms = $content;}if(ENC_IS_GBK) $sms = ENC_G2U($sms);if (strlen($phone) >13) $phone = str_replace(';',',',$phone);$url = $this->Gateway;$url .= 'sms?';$post = 'u='.$this->cfg['account'].'&p='.md5($this->cfg['password']).'&m='.$phone.'&c='.urlencode($sms);$this->Debug('Request: Started');$this->Debug('Send: '.htmlspecialchars($smsb));$result = $this->Get($url,$post);if ($result == ''){$this->Error('Connected Failed.');return $this->result_error('reponse-empty');}$result = strip_tags($result);$this->Debug('Response: '.htmlspecialchars($result));$code = (int)$result;if ($this->IMSend_IS_SUCC($code)){$this->Debug('Status: Send success.');}return $this->result_success($this->IMSend_STATUS($code),array('status'=>($this->IMSend_IS_SUCC($code) ?'success': 'failed')));}public function IMStatus(){$url = $this->Gateway;$url .= 'query?';$url .= 'u='.$this->cfg['account'].'&p='.md5($this->cfg['password']);$result = $this->Get($url);//$result = strip_tags($result);$ret = explode(",", $result);if ($ret[1] >=0){$status = '響應正常';}else{$status = '響應異常';}return sprintf('通道狀態(tài):%s<br/>短信剩余:%d 條',$status,$ret[1]);}private function IMSend_IS_SUCC($code){if ( (int)$code >0){return true;}else{return false;}}private function IMSend_STATUS($code){$code_STA = array('40'=>'賬號不存在','30'=>'用戶名或密碼錯誤','41'=>'余額不足','42'=>'賬號過期','43'=>'ip地址限制','50'=>'內(nèi)容含有敏感詞','51'=>'手機號碼不正確',);if (isset($code_STA[$code])){return $code_STA[$code];}elseif((int)$code ==0){return '發(fā)送短信成功';}else{return 'ERROR'.$code;}}}?> |
最后在更目錄下創(chuàng)建\insertdata\文件添加insert.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
|
<?php class connectSQL{ private $host ; private $name ; private $pwd ; private $db ; public function init($host,$name,$passwd,$database,$tb){ $this->host = $host; $this->name = $name; $this->pwd = $passwd; $this->db = $database; $this->table = $tb; $this->init_conn(); } private function init_conn(){ $this->conn=@mysql_connect($this->host,$this->name,$this->pwd); if(!$this->conn) die("鏈接MySQL失敗".mysql_error()); else //echo"連接MySQL成功!<br>"; @mysql_select_db($this->db,$this->conn); @mysql_query("set names 'utf8'"); } private function mysql_query_rst($sql){ if($this->conn =='') $this->init_conn(); $this->result = @mysql_query($sql,$this->conn); return $this->result; } private function mysql_insert($sql){ return $this->mysql_query_rst($sql); } public function toInsert(){ $sql="INSERT INTO `".$this->db."`.`cenwor_tttuangou_service` (`id`, `type`, `flag`, `name`, `weight`, `count`, `config`, `enabled`, `update`, `surplus`) VALUES ('0', 'sms', 'smsbao', '短信寶通道', '100', '0', 'a:6:{s:6:\"driver\";s:6:\"smsbao\";s:7:\"account\";s:6:\"test\";s:8:\"password\";s:8:\"123456\";s:4:\"sign\";s:4:\"[77]\";s:5:\"bcmax\";s:3:\"222\";s:4:\"sinv\";s:1:\"0\";}', 'false', '1391862128', '2')"; if( $this->mysql_insert($sql)){ echo "job done"; } else{ echo "job failed".$sql; } } } include_once '../setting/settings.php'; $sql_connect = new connectSQL(); $sql_connect->init($config['settings']['db_host'], $config['settings']['db_user'], $config['settings']['db_pass'], $config['settings']['db_name'],$config['settings']['db_table_prefix']."tttuangou_service"); $sql_connect->toInsert();?> |
好了,經(jīng)過以上的替換,短信寶的短信平臺已經(jīng)替換成功了,可以正常使用了。我們進行測試發(fā)送。

報備一下短信寶的VIP模板,這樣就可以走短信寶的優(yōu)質(zhì)通道了,即便遇到敏感文字我們都不會人工審核,短信內(nèi)容3~5秒就可送達。
另外:我們已經(jīng)開發(fā)好完整的天天團購系統(tǒng)短信寶插件,點擊此鏈接 下載及查看安裝流程。
最新更新
電商類
CMS類
微信類