kppw社區(qū)是基于PHP5.x+Mysql5.x開(kāi)發(fā)的一款系統(tǒng)平臺(tái),采用的是一種簡(jiǎn)單的MVC模式,內(nèi)核采用OO模式,控制層采用的是基于面向過(guò)程的模式。今天小編就以替換短信接口為例一步一步教大家如何開(kāi)發(fā),進(jìn)行替換的短信接口是我們短信寶短信群發(fā)平臺(tái)的短信接口,我們短信寶短信接口非常穩(wěn)定,發(fā)送速度快,注冊(cè)還送測(cè)試短信,推薦大家使用。
首先我們代開(kāi)項(xiàng)目根目錄下\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' => [ //請(qǐng)求地址 //短信寶用戶名 'smsbaoName' => '你的短信寶用戶名' , //短信寶密碼 'smsbaoPass' => '你的短信寶密碼' , //短信寶簽名 'smsbaoSign' => '你的短信簽名' , ], |
接著在項(xiàng)目\vendor\toplan\phpsms\src\phpsms\agents\下創(chuàng)建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 ) { } } |
好了,經(jīng)過(guò)以上的替換,短信寶的短信平臺(tái)已經(jīng)替換成功了,可以正常使用了。我們進(jìn)行測(cè)試發(fā)送。
報(bào)備一下短信寶的VIP模板,這樣就可以走短信寶的優(yōu)質(zhì)通道了,即便遇到敏感文字我們都不會(huì)人工審核,短信內(nèi)容3~5秒就可送達(dá)。
另外:我們已經(jīng)開(kāi)發(fā)好完整的kppw威客社區(qū)短信寶插件,點(diǎn)擊此鏈接 下載及查看安裝流程。
最新更新
電商類
CMS類
微信類