螞蟻分類是一款基于php+mysql的分類信息/地方門戶網站建站系統.為在各種服務器上架設分類信息網站提供完美的解決方案。它是免費的和開源的,使用范圍非常廣泛,小編對他還是比較了解的,今天小編為大家講解mymps 5.9E UTF-8版本的短信接口替換,使用的接口是我們短信寶群發平臺的短信接口,我們短信寶群發短信平臺非常穩定,發送速度快,注冊還送測試短信,推薦大家使用。
1:打開項目:/admin/template/sms_setting.tpl.php 新增短信寶頁面 大概15行代碼
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
<?php include mymps_tpl('inc_head');?><form method="post" action="sms.php?part=<?=$part?>"><div id="<?=MPS_SOFTNAME?>"><table border="0" cellspacing="0" cellpadding="0" class="vbm"><tr class="firstr"><td colspan="2">配置短信供應商接口</td></tr><tr bgcolor="#ffffff"><td width="25%">供應商: </td><td><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><label for="weimi"><input name="sms_service" type="radio" class="radio" id="weimi" value="weimi" onclick='document.getElementById("sms_div").style.display = "";' <?php if($sms_config[sms_service] == 'weimi'){?>checked="checked"<?}?>>通道三</label> <label for="smsbao"><input name="sms_service" type="radio" class="radio" id="smsbao" value="smsbao" onclick='document.getElementById("sms_div").style.display = "";' <?php if($sms_config[sms_service] == 'smsbao'){?>checked="checked"<?}?>>短信寶</label><label for="no"><input class="radio" name="sms_service" type="radio" id="no" value="no" onclick='document.getElementById("sms_div").style.display = "none";' <?php if($sms_config[sms_service] == 'no' || empty($sms_config[sms_service])){?>checked="checked"<?}?>>不啟用</label></td></tr> |
2:打開項目:/include下創建一個smsbao文件夾,在smsbao下創建一個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
|
<?phpfunction Post($curlPost, $url){ $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_HEADER, false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_NOBODY, true); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POSTFIELDS, $curlPost); $return_str = curl_exec($curl); curl_close($curl); return $return_str;}function xml_to_array($xml){ $reg = '/<(\\w+)[^>]*>([\\x00-\\xFF]*)<\\/\\1>/'; if (preg_match_all($reg, $xml, $matches)) { $count = count($matches[0]); for ($i = 0; $i < $count; $i++) { $subxml = $matches[2][$i]; $key = $matches[1][$i]; if (preg_match($reg, $subxml)) { $arr[$key] = xml_to_array($subxml); } else { $arr[$key] = $subxml; } } } return $arr;}function msend_sms($sms_user, $sms_pwd, $mobile, $content){ global $charset; $statusStr = array(0 => '短信發送成功', -1 => '參數不全', -2 => '服務器空間不支持,請確認支持curl或者fsocket,聯系您的空間商解決或者更換空間!', 30 => '密碼錯誤', 40 => '賬號不存在', 41 => '余額不足', 42 => '帳戶已過期', 43 => 'IP地址限制', 50 => '內容含有敏感詞'); $user = $sms_user; $pass = md5($sms_pwd); $content = rawurlencode($content); $phone = $mobile; $sendurl = $smsapi . 'sms?u=' . $user . '&p=' . $pass . '&m=' . $phone . '&c=' . $content; $result = file_get_contents($sendurl); $gets['SubmitResult']['code'] = $result; $gets['SubmitResult']['msg'] = $charset == 'gbk' ? iconv('UTF-8', 'GBK', $statusStr[$result]) : $statusStr[$result]; return $gets;}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 : '您的驗證碼是' . $yzm . '請不要把驗證碼泄露給其他人。如非本人操作,可不用理會!'; $status = msend_sms($sms_user, $sms_pwd, $mobile, $content); if ($status['SubmitResult']['code'] == 0) { } write_sms_sendrecord($mobile, $content, $status['SubmitResult']['msg'], '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 : '您的手機號:' . $mobile . ',找回密碼驗證碼:' . $yzm . ',請不要把驗證碼泄露給其他人。如非本人操作,可不用理會!'; $status = msend_sms($sms_user, $sms_pwd, $mobile, $content); if ($status['SubmitResult']['code'] == 0) { } write_sms_sendrecord($mobile, $content, $status['SubmitResult']['msg'], 'smsbao');}?> |
好了,經過以上的替換,短信寶的短信平臺已經替換成功了,可以正常使用了。我們進行測試發送。
報備一下短信寶的VIP模板,這樣就可以走短信寶的優質通道了,即便遇到敏感文字我們都不會人工審核,短信內容3~5秒就可送達。
另外:我們已經開發好完整的螞蟻分類5.9E系統短信寶插件,點擊此鏈接 下載及查看安裝流程。
最新更新
電商類
CMS類
微信類