91成人在线播放_欧美一区二区视频在线观看_91精品国产高清久久久久久_国产精品久久亚洲不卡4k岛国


待發短信

在線客服
產品支持 短信寶客服
合作渠道 渠道合作
服務咨詢

4001-021-502

工作時間

9:00-21:00

螞蟻分類短信接口替換

螞蟻分類是一款基于php+mysql的分類信息/地方門戶網站建站系統.為在各種服務器上架設分類信息網站提供完美的解決方案。它是免費的和開源的,使用范圍非常廣泛。本人對該系統還是比較熟悉的,今天我就來分享一下,如何進行二次開發。我以替換短信接口為例,一步一步的手把手教大家開發過程,我們做演示的短信平臺是短信寶(http://www.gjrencai.com)短信平臺,我們公司和短信寶平臺合作好幾年了,他們的平臺非常穩定,而且快速,注冊還送免費測試短信,大家可以在短信寶平臺注冊一個賬號,進行測試。

首先,我們先更換后臺的顯示界面文件。打開模板文件,替換一下模板文件。打開項目/admin/template/sms_setting.tpl.php,替換的代碼為8~14行,代碼如下圖所示:

?
1
2
3
4
if ($sms_config[sms_service] == 'smsbao') {
    echo 'checked="checked"';
}
echo ">短信寶,點擊<a href='http://www.gjrencai.com' target='_blank'>免費注冊</a></label>" "\r\n" '<label for="ihuyi"> <input name="sms_service" type="radio" class="radio" id="ihuyi" value="ihuyi" onclick=\'document.getElementById("sms_div").style.display = "";\' ';

經過替換后,所有的顯示都變成短信寶短信平臺的了。第一步完成。接下來替換發送短信的業務代碼。在項目/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
70
71
72
73
74
75
76
77
78
<?php
 
/**
* 發送http請求
* @access protected
* @param string $url  請求地址
* @param string $param  get方式請求內容,數組形式,post方式時無效
* * @param string $data  post請求方式時的內容,get方式時無效
* @param string $method  請求方式,默認get
*/
function http($url$param$data ''$method 'GET'){
    $opts array(
        CURLOPT_TIMEOUT        => 30,
        CURLOPT_RETURNTRANSFER => 1,
        CURLOPT_SSL_VERIFYPEER => false,
        CURLOPT_SSL_VERIFYHOST => false,
    );
 
    /* 根據請求類型設置特定參數 */
    $opts[CURLOPT_URL] = $url '?' . http_build_query($param);
 
    if(strtoupper($method) == 'POST'){
        $opts[CURLOPT_POST] = 1;
        $opts[CURLOPT_POSTFIELDS] = $data;
 
        if(is_string($data)){ //發送JSON數據
            $opts[CURLOPT_HTTPHEADER] = array(
                'Content-Type: application/json; charset=utf-8',
                'Content-Length: ' strlen($data),
            );
        }
    }
 
    /* 初始化并執行curl請求 */
    $ch = curl_init();
    curl_setopt_array($ch$opts);
    $data  = curl_exec($ch);
    $error = curl_error($ch);
    curl_close($ch);
 
    //發生錯誤,拋出異常
    if($errorthrow new \Exception('請求發生錯誤:' $error);
 
    return  $data;
}
 
function msend_sms($sms_user$sms_pwd$mobile$content)
{
 
    $target 'http://api.smsbao.com/sms';
    $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 '您的驗證碼是:' $yzm '。請不要把驗證碼泄露給其他人。如非本人操作,可不用理會!');
    $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 '您的手機號:' $mobile ',找回密碼驗證碼:' $yzm ',請不要把驗證碼泄露給其他人。如非本人操作,可不用理會!');
    $status = msend_sms($sms_user$sms_pwd$mobile$content);
    write_sms_sendrecord($mobile$content$status'smsbao');
}
 
 
?>

好了,經過以上的替換,短信寶的短信平臺已經替換成功了,可以正常使用了。我們進行測試發送。

報備一下短信寶的VIP模板,這樣就可以走短信寶的優質通道了,并且免審核了,短信內容3~5秒就可送達。
開源插件

最新更新

電商類

CMS類

微信類

文章標簽