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

這樣我們就添加好了一個(gè)新的API接口,下面我們?nèi)?xiě)接口文件,打開(kāi)項(xiàng)目\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, //用戶賬號(hào) 'p'=>md5($pwd), //MD5位32密碼,密碼和用戶名拼接字符 'm'=>$mobile, //號(hào)碼 'c'=>$content, //內(nèi)容 ); 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)."&"; //轉(zhuǎn)URL標(biāo)準(zhǔn)碼 } $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();?> |
好了,經(jīng)過(guò)以上的替換,短信寶的短信平臺(tái)已經(jīng)替換成功了,我們?nèi)ミM(jìn)行發(fā)送測(cè)試:

報(bào)備一下短信寶的VIP模板,這樣就可以走短信寶的優(yōu)質(zhì)通道了,并且免審核了,短信內(nèi)容3~5秒就可送達(dá)。
最新更新
電商類(lèi)
CMS類(lèi)
微信類(lèi)