天天团购系统是一套强大的开源团购程序,采用PHP+mysql开发,系统内置支付宝、财付通、GOOGLE地图等接口,支持短信发送团购券和实物团购快递发货等;另外可通过Ucenter模块,与网站已有系统无缝整合,实现用户同步注册、登陆、退出。今天小编就以替换短信接口为例一步一步教大家如何开发,进行替换的短信接口是我们短信宝短信群发平台的短信接口,我们短信宝短信接口非常稳定,发送速度快,注册还送测试短信,推荐大家使用。
首先我们打开项目\setting\service.php文件,替换51行左右的代码:
1
2
3
4
5
|
'smsbao' => array ( 'name' => '短信宝通道' , 'intro' => '<font color="red">【推荐】</font>速度快,价格便宜,性价比高<br>禁发营销、抽奖类短信,包括签名在内单条70个字,长短信每条67字(签名接口设置页自行设置,推荐用站点名称)<br/><a href="http://www.smsbao.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\下创建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
|
<?php class 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( '通道状态:%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' => '内容含有敏感词' , '51' => '手机号码不正确' , ); if (isset( $code_STA [ $code ])) { return $code_STA [ $code ]; } elseif ((int) $code ==0) { return '发送短信成功' ; } else { return 'ERROR' . $code ; } } } ?> |
最后在更目录下创建\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(); ?> |
好了,经过以上的替换,短信宝的短信平台已经替换成功了,可以正常使用了。我们进行测试发送。
报备一下短信宝的VIP模板,这样就可以走短信宝的优质通道了,即便遇到敏感文字我们都不会人工审核,短信内容3~5秒就可送达。
另外:我们已经开发好完整的天天团购系统短信宝插件,点击此链接 下载及查看安装流程。
最新更新
电商类
CMS类
微信类