OURPHP是一個品牌,一款基于PHP+MySQL開發符合W3C標準的建站系統。是一套非常適用建站者使用的程序,二次開發也比較方便,小編對這款系統還是比較了解的,今天小編就以新增短信接口為例告訴大家如何進行二次開發,我們今天講解的是1.7.6版本的,我們使用的短信接口是我們短信寶短信群發平臺的短信接口,我們短信寶短信群發平臺的短信接口非常穩定,發送速度快,注冊就送測試短信,推薦大家使用。
首先我們需要在后臺添加一個新的API接口,我們進入后臺->全局->API接口管理,添加API接口,接口內容為 短信寶短信接口|1|短信寶用戶名|短信寶密碼 ,修改短信寶用戶名和密碼為我們自己的,提交。

這樣我們就添加好了一個新的API接口,下面我們去寫接口文件,打開項目\function\api\telcode\user_regcode.class.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
|
<?phpclass ourphpsms{ public function smsconfig($m='',$c='',$s='',$t=1){ global $db; $rs = $db -> select("OP_Key","`ourphp_api`"," where OP_Key LIKE '%短信寶%'"); $rs = explode('|',$rs[0]); if($rs[1] == 2){ return false; }else{ $uid = $rs[2]; $pwd = $rs[3]; $mobile = $m; $mobileids = ''; $content = $c; return $this->sendSMS($http,$uid,$pwd,$mobile,$content,$mobileids,$sign); } } function sendSMS($http,$uid,$pwd,$mobile,$content,$mobileids,$time='',$mid=''){ $data = array ( 'u'=>$uid, //用戶賬號 'p'=>md5($pwd), //MD5位32密碼,密碼和用戶名拼接字符 'm'=>$mobile, //號碼 'c'=>$content, //內容 ); return $this->postSMS($http,$data); //POST方式提交 } function postSMS($url,$data=''){ $port=""; $post=""; $row = parse_url($url); $host = $row['host']; @$port = $row['port'] ? $row['port']:80; $file = $row['path']; while (list($k,$v) = each($data)) { $post .= rawurlencode($k)."=".rawurlencode($v)."&"; //轉URL標準碼 } $post = substr( $post , 0 , -1 ); $len = strlen($post); $fp = @fsockopen( $host ,$port, $errno, $errstr, 10); if (!$fp) { return "$errstr ($errno)\n"; } else { $receive = ''; $out = "POST $file HTTP/1.1\r\n"; $out .= "Host: $host\r\n"; $out .= "Content-type: application/x-www-form-urlencoded\r\n"; $out .= "Connection: Close\r\n"; $out .= "Content-Length: $len\r\n\r\n"; $out .= $post; fwrite($fp, $out); while (!feof($fp)) { $receive .= fgets($fp, 128); } fclose($fp); $receive = explode("\r\n\r\n",$receive); unset($receive[0]); //return implode("",$receive); return ""; } }}$smskey = new ourphpsms();?> |
好了,經過以上的替換,短信寶的短信平臺已經替換成功了,我們去進行發送測試:

報備一下短信寶的VIP模板,這樣就可以走短信寶的優質通道了,并且免審核了,短信內容3~5秒就可送達。
最新更新
電商類
CMS類
微信類