螞蟻分類是一款基于php+mysql的分類信息/地方門戶網(wǎng)站建站系統(tǒng).為在各種服務(wù)器上架設(shè)分類信息網(wǎng)站提供完美的解決方案。它是免費(fèi)的和開源的,使用范圍非常廣泛,小編對(duì)他還是比較了解的,今天小編為大家講解mymps 5.8SE UTF-8版本的短信接口替換,使用的接口是我們短信寶群發(fā)平臺(tái)的短信接口,我們短信寶群發(fā)短信平臺(tái)非常穩(wěn)定,發(fā)送速度快,注冊(cè)還送測試短信,推薦大家使用。
首先,我們先更換后臺(tái)的顯示界面文件。打開模板文件,替換一下模板文件。打開項(xiàng)目/admin/template/sms_setting.tpl.php,替換的代碼為11~14行,代碼如下圖所示:
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
<label for="dxton"><input class="radio" name="sms_service" type="radio" id="dxton" value="dxton" onclick='document.getElementById("sms_div").style.display = "";'<?php if($sms_config[sms_service] == 'dxton'){?>checked="checked"<?}?>></label><label for="ihuyi"><input name="sms_service" type="radio" class="radio" id="ihuyi" value="ihuyi" onclick='document.getElementById("sms_div").style.display = "";'<?php if($sms_config[sms_service] == 'ihuyi'){?>checked="checked"<?}?>>通道二</label> |
經(jīng)過替換后,第一步完成,接下來替換發(fā)送短信的業(yè)務(wù)代碼。修改項(xiàng)目/include/dxton下mymps.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
75
76
77
|
<?php/** * 發(fā)送http請(qǐng)求 * @access protected * @param string $url 請(qǐng)求地址 * @param string $param get方式請(qǐng)求內(nèi)容,數(shù)組形式,post方式時(shí)無效 * * @param string $data post請(qǐng)求方式時(shí)的內(nèi)容,get方式時(shí)無效 * @param string $method 請(qǐng)求方式,默認(rèn)get */function http($url, $param, $data = '', $method = 'GET'){ $opts = array( CURLOPT_RETURNTRANSFER => 1, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => false, ); /* 根據(jù)請(qǐng)求類型設(shè)置特定參數(shù) */ $opts[CURLOPT_URL] = $url . '?' . http_build_query($param); if(strtoupper($method) == 'POST'){ $opts[CURLOPT_POST] = 1; $opts[CURLOPT_POSTFIELDS] = $data; if(is_string($data)){ //發(fā)送JSON數(shù)據(jù) $opts[CURLOPT_HTTPHEADER] = array( 'Content-Type: application/json; charset=utf-8', 'Content-Length: ' . strlen($data), ); } } /* 初始化并執(zhí)行curl請(qǐng)求 */ $ch = curl_init(); curl_setopt_array($ch, $opts); $data = curl_exec($ch); $error = curl_error($ch); curl_close($ch); //發(fā)生錯(cuò)誤,拋出異常 if($error) throw new \Exception('請(qǐng)求發(fā)生錯(cuò)誤:' . $error); return $data;}function msend_sms($sms_user, $sms_pwd, $mobile, $content){ $post_data['u']=$sms_user; $post_data['p']=md5($sms_pwd); $post_data['m']=$mobile; $post_data['c']=$content; echo $content; return $gets = http($target, $post_data);}function msend_regsms($sms_user, $sms_pwd, $mobile, $yzm, $sms_regtpl = ''){ $content = str_replace('{code}', $yzm, $sms_regtpl); $content = str_replace('{mobile}', $mobile, $content); $content = ($content ? $content : '您的驗(yàn)證碼是:' . $yzm . '。請(qǐng)不要把驗(yàn)證碼泄露給其他人。如非本人操作,可不用理會(huì)!'); $status = msend_sms($sms_user, $sms_pwd, $mobile, $content); write_sms_sendrecord($mobile, $content, $status, 'smsbao');}function msend_pwdsms($sms_user, $sms_pwd, $mobile, $yzm, $sms_pwdtpl = ''){ $content = str_replace('{code}', $yzm, $sms_pwdtpl); $content = str_replace('{mobile}', $mobile, $content); $content = ($content ? $content : '您的手機(jī)號(hào):' . $mobile . ',找回密碼驗(yàn)證碼:' . $yzm . ',請(qǐng)不要把驗(yàn)證碼泄露給其他人。如非本人操作,可不用理會(huì)!'); $status = msend_sms($sms_user, $sms_pwd, $mobile, $content); write_sms_sendrecord($mobile, $content, $status, 'smsbao');}?> |
好了,經(jīng)過以上的替換,短信寶的短信平臺(tái)已經(jīng)替換成功了,可以正常使用了。我們進(jìn)行測試發(fā)送。

報(bào)備一下短信寶的VIP模板,這樣就可以走短信寶的優(yōu)質(zhì)通道了,即便遇到敏感文字我們都不會(huì)人工審核,短信內(nèi)容3~5秒就可送達(dá)。
另外:我們已經(jīng)開發(fā)好完整的螞蟻分類系統(tǒng)短信寶插件,點(diǎn)擊此鏈接 下載及查看安裝流程。
最新更新
電商類
CMS類
微信類