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


待發短信

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

4001-021-502

工作時間

9:00-21:00

ECJIA到家V1.4.2短信插件開發

ECJia移動商城系統(EC+)是一款基于移動互聯網的商城應用服務產品,擁有執行效率高、上手輕松、管理便捷等一系列優點。前段時間小編為大家介紹了這款軟件如何開發短信插件,版本不一樣插件也就不一樣了,今天小編為大家講解一下ECJIA1.4.2這個版本的短信插件該如何開發,短信接口使用的是我們短信寶短信群發平臺,我們短信寶短信群發平臺極其穩定,而且短信發送速度相當快捷,驗證碼和訂單通知在3~5秒就能收到,用戶體驗非常好,注冊就送測試短信。

1.4.2這個版本我們只需要修改項目\content\system\classes\ecjia_sms.class.php文件就可以了,這個文件是ecjia短信發送類,我們修改如下代碼:

?
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
<?php
 
 
/**
 * ECJIA SMS
 */
defined('IN_ECJIA'or exit('No permission resources.');
 
/* 短信模塊主類 */
class ecjia_sms {
    const HOST      = 'http://api.smsbao.com/sms?';
    const SEND      = 'method=Submit';
    const BALANCE   = 'method=GetNum';
    const PASSWORD  = 'method=ChangePassword';
    
    private $_account;
    private $_password;
    private $_auth;
    private $_sender;
    private $_message;
    private $_type;
    private $_sms;
    
    protected $to array();
    private $response_code array(
        '0'  => 'SUCCESS - Message Sent.',
        '30' => '密碼錯誤',
        '40' => '賬號不存在',
        '41' => '余額不足',
        '42' => '賬號過期',
        '43' => 'IP地址限制',
        '50' => '內容含有敏感詞',
        '51' => '手機號碼不正確'
    );
    
    /**
     * Create SMS instance
     *
     * @return  void
     */
    public static function make()
    {
        return new static();
    }
 
    public function __construct($account = null, $password = null) 
    {
        /* 直接賦值 */
        $this->_account  = $account $account : ecjia::config('sms_user_name');
        $this->_password = $password $password : MD5(ecjia::config('sms_password'));
        $this->_type = 1;
        $this->_sender = '';
        $this->_auth = $this->getAuthParams();
    }
    
    public function setNumber($number) {
        $this->addAnNumber($number);
        return $this;
    }
    
    public function getNumber()
    {
        return $this->_to;
    }
    
    /**
     * 添加信息
     * 如果內容有url需要過濾,可以使用rawurlencode方法
     * @param unknown $msg
     * @return string
     */
    public function setMessage($msg)
    {
        $this->_message = $msg;
        return $this;
    }
    
    public function getMessage()
    {
        return $this->_message;
    }
    
    public function viewSMSParams()
    {
        return $this->getSMSParams();
    }
    
    public function normalize($number)
    {
        return $this->normalizeNumber($number);
    }
    
    public function send()
    {
        $response array();
        
        $result $this->sendSMS( is_array($this->_to) ? $this->formatNumber($this->_to) : $this->_to );
        $response['raw'] = $result;
        $response['code'] = $result=='0'?2:$result;
        $response['description'] = $this->response_code["$result"];
        return $response;
    }
    
    private function sendSMS($mobile) {
        $url = self::HOST ;
        $params $this->_auth;
        $params['c']  = $this->_message;
        $params['m']   = $mobile;
        return $this->curl( $url$params );
    }
    
    public function balance()
    {
        $response array();
        
        $url "http://www.gjrencai.com/query?";
        $params $this->_auth;
        $result $this->curl( $url$params );
                $info=explode(",",trim($result));
        
        $response['num'] = $info[1];
        $response['code'] = 2;
        $response['description'] = $info->msg;
        
        return $response;
    }
    
    private function addAnNumber($number)
    {
        if (is_array($number)) {
            foreach ($number as $num)
            {
                $this->_to[] = $num;
            }
        else {
            $this->_to[] = $number;
        }
    
    }
    
    private function normalizeNumber($number$countryCode = 86)
    {
        if (isset($number)) {
            $number = trim($number);
            $number str_replace("+"""$number);
            preg_match( '/(0|\+?\d{2})(\d{8,9})/'$number$matches);
            if ((int) $matches[1] === 0 ) {
                $number $countryCode $matches[2];
            }
        }
        return $number;
    }
    
    private function formatNumber($number)
    {
        $format "";
        if (is_array($number)) {
            $format = implode(";"$number);
        }
        return $format;
    }
    
    private function getInfo($result)
    {
        $result_arr = RC_Xml::to_array($result);
        
        $info new stdClass();
        $info->code     =  $result_arr['code'][0];
        $info->msg      = $result_arr['msg'][0];
        
        if (isset($result_arr['smsid'])) {
            $info->smsid = $result_arr['smsid'][0];
        }
        
        if (isset($result_arr['num'])) {
            $info->num   = $result_arr['num'][0];
        }
         
        return $info;
    }
    
    private function getAuthParams()
    {
        $params['u']  = $this->_account;
        $params['p'] = $this->_password;
        return $params;
    }
    
    private function getSMSParams()
    {
        $params['m']   = $this->formatNumber($this->_to);
        $params['c']  = $this->_message;
        return $params;
    }
    
    private function getAnswer( $code )
    {
        if ( isset( $this->response_code[$code] ) ) {
            return $this->response_code[$code];
        }
    }
    
    private function curl( $url$params array() )
    {
        
        $ch = curl_init();
        $options array(
            CURLOPT_RETURNTRANSFER  => TRUE,
            CURLOPT_URL             => $url,
            CURLOPT_HEADER          => false,
            CURLOPT_ENCODING        => "",
            CURLOPT_POST            => 1,
            CURLOPT_POSTFIELDS      => $params,
            CURLOPT_SSL_VERIFYHOST  => 0,
            CURLOPT_SSL_VERIFYPEER  => false,
        );
        curl_setopt_array( $ch$options );
        $result = curl_exec( $ch );
        curl_close( $ch );
    
        return $result;
    }
    
}

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


 

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

最新更新

電商類

CMS類

微信類

文章標簽