kppw社區是基于PHP5.x+Mysql5.x開發的一款系統平臺,采用的是一種簡單的MVC模式,內核采用OO模式,控制層采用的是基于面向過程的模式。今天小編就以替換短信接口為例一步一步教大家如何開發,進行替換的短信接口是我們短信寶短信群發平臺的短信接口,我們短信寶短信接口非常穩定,發送速度快,注冊還送測試短信,推薦大家使用。
首先我們代開項目根目錄下\config\phpsms.php文件,添加短信寶配置信息,代碼如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
/* * ----------------------------------- * Smsbao * 短信寶 * ----------------------------------- * website:http://www.gjrencai.com * support template sms. */ 'Smsbao' => [ //請求地址 //短信寶用戶名 'smsbaoName' => '你的短信寶用戶名' , //短信寶密碼 'smsbaoPass' => '你的短信寶密碼' , //短信寶簽名 'smsbaoSign' => '你的短信簽名' , ], |
接著在項目\vendor\toplan\phpsms\src\phpsms\agents\下創建SmsbaoAgent.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
|
<?php namespace Toplan\PhpSms; use REST; /** * 短信寶 */ class SmsbaoAgent extends Agent { public function sendSms( $to , $content , $tempId , array $data ) { $content = explode ( '】' , $content ); $url = $this ->smsbaoUrl. '?u=' . $this ->smsbaoName. '&p=' .md5( $this ->smsbaoPass). '&m=' . $to . '&c=【' . $this ->smsbaoSign. '】' . $content [1]; $ret = file_get_contents ( $url ); return $this ->setResult( $ret ); } public function sendTemplateSms( $to , $tempId , array $data ) { } public function voiceVerify( $to , $code , $tempId , array $data ) { } protected function setResult( $result ) { if ( $result == 0){ $success = true; } else { $success = false; } $this ->result(Agent::SUCCESS, $success ); // $this->result(Agent::CODE, $code); // $this->result(Agent::INFO, $info); } public function sendContentSms( $to , $content ) { } } |
好了,經過以上的替換,短信寶的短信平臺已經替換成功了,可以正常使用了。我們進行測試發送。
報備一下短信寶的VIP模板,這樣就可以走短信寶的優質通道了,即便遇到敏感文字我們都不會人工審核,短信內容3~5秒就可送達。
另外:我們已經開發好完整的kppw威客社區短信寶插件,點擊此鏈接 下載及查看安裝流程。
最新更新
電商類
CMS類
微信類