ThinkLC是一款基于PHP+MYSQL開發(fā)的地方分類信息系統(tǒng),完全面向?qū)ο蟮募夹g(shù)架構(gòu)設(shè)計(jì)開發(fā)。便于二次開發(fā),小編對(duì)于這款軟件還是比較了解的,下面小編就帶著大家一起進(jìn)行短信接口的新增開發(fā)。使用的短信接口是我們短信寶短信群發(fā)平臺(tái)的接口,我們短信寶短信群發(fā)平臺(tái)非常穩(wěn)定,發(fā)送速度快,注冊(cè)還送測(cè)試短信,推薦大家使用。
ThinkLC的短信接口都是放在SaxueFrame\sms文件夾中,我們首先新建一個(gè)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
|
<?php header( "Content-type:text/html; charset=UTF-8" ); //編碼格式 /** * 短信寶短信接口 */ class saxuesms extends saxueobject { protected $statusStr = array ( "0" => "短信發(fā)送成功" , "-1" => "參數(shù)不全" , "-2" => "服務(wù)器空間不支持,請(qǐng)確認(rèn)支持curl或者fsocket,聯(lián)系您的空間商解決或者更換空間!" , "30" => "密碼錯(cuò)誤" , "40" => "賬號(hào)不存在" , "41" => "余額不足" , "42" => "帳戶已過期" , "43" => "IP地址限制" , "50" => "內(nèi)容含有敏感詞" ); protected $uid = '' ; //短信寶帳號(hào) protected $pass = '' ; //短信寶密碼 protected $sign = '' ; //短信簽名 protected $mobile = '' ; protected $content = '' ; public function __construct( $mobile , $content , $iscode = true ) { $this ->mobile = $mobile ; if ( empty ( $mobile )) { $this ->raiseerror( '手機(jī)號(hào)碼不能為空' ,SAXUE_ERROR_RETURN); } if ( $iscode ) { $this ->content = '【' . $this ->sign. '】您的驗(yàn)證碼:' . $content . '(10分鐘內(nèi)有效)' ; } else { $this ->content = $content ; } } public function sendsms() { $url = 'http://api.smsbao.com/sms?u=' . $this ->uid. '&p=' .md5( $this ->pass). '&m=' . $this ->mobile. '&c=' . $this ->content; $request = $this ->SmsPost( $url ); if ( $request != 0) { $this ->raiseerror( '錯(cuò)誤代碼:' . $statusStr [ $request ],SAXUE_ERROR_RETURN); } } protected function SmsPost( $url ){ if (function_exists( 'file_get_contents' )){ $file_contents = file_get_contents ( $url ); } else { $ch = curl_init(); $timeout = 5; curl_setopt( $ch , CURLOPT_URL, $url ); curl_setopt( $ch , CURLOPT_RETURNTRANSFER, 1); curl_setopt( $ch , CURLOPT_CONNECTTIMEOUT, $timeout ); $file_contents = curl_exec( $ch ); curl_close( $ch ); } return $file_contents ; } } ?> |
好了,經(jīng)過以上的創(chuàng)建,短信寶的短信平臺(tái)已經(jīng)替換成功了,可以正常使用了。進(jìn)行發(fā)送測(cè)試:
報(bào)備一下短信寶的VIP模板,這樣就可以走短信寶的優(yōu)質(zhì)通道了,并且免審核了,短信內(nèi)容3~5秒就可送達(dá)。
最新更新
電商類
CMS類
微信類