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


待發(fā)短信

在線客服
產(chǎn)品支持 短信寶客服
合作渠道 渠道合作
服務(wù)咨詢

4001-021-502

工作時間

9:00-21:00

UQCMS云商系統(tǒng)新增短信寶短信接口

UQCMS云商是一款B2B2C電子商務(wù)軟件 ,采用PHP+MYSQL,模板采用smarty模板,二次開發(fā),簡單方便,無需學(xué)習(xí)其他框架就可以自行模板設(shè)計。永久免費(fèi)使用,操作簡單,安全穩(wěn)定。今天小編一步一步教大家如何開發(fā),進(jìn)行替換的短信接口是我們短信寶短信群發(fā)平臺的短信接口,我們短信寶短信接口非常穩(wěn)定,發(fā)送速度快,注冊還送測試短信,推薦大家使用。

首先我們在項(xiàng)目\home\controls\目錄下創(chuàng)建smsbao.class.php文件,代碼如下:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?php
class smsbao_uqcms extends control{
 public function index() {
  $sql[] =  "insert into ".table('api_sms')." (`id`,`alias`,`name`,`describe`,`app_key`,`app_secret`,`sign`,`status`,`left_delimiter`,`right_delimiter`) values ('','smsbao','短信寶短信','短信寶短信:http://www.gjrencai.com/','','','','0','{','}')";
  $sql[] = "insert into ".table('api_notice_tpl')." (`id`, `nid`, `type`, `type2`, `name`,`tpl_id`, `param`, `param2`,`content`,`status`) values ('','1','sms','smsbao','驗(yàn)證碼短信','','smscode','code','你的驗(yàn)證碼為:{code} 為保證您的賬戶安全,請勿泄露.','1')";
  foreach ($sql as $val) {
   if (!$query $query=$this->db->query($val)) {
    echo '執(zhí)行sql語句成功';
    exit;
   }
  }
  echo "<h4>UQCMS短信寶短信插件安裝成功,請刪除此文件。</h4>";
 }
}

接著我們打開項(xiàng)目\module\api.mod.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
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
225
226
227
228
229
230
class api_mod extends module {
    function __construct() {
        $this->uid = @$_SESSION['user']['uid'];
        parent::__construct();
    }
    function notice($type$tpl_name$arr) {
        $query $this->notice_sms($row['username'], $row['tpl_name'], $arr);
        if ($type == 'sms' || $type == 'email' || $type == 'wxtpl') {
            if (!empty($this->uid)) {$setarr['uid'] = $this->uid;
            else { $setarr['uid'] = '0'; }
            $setarr['type'] = $type;
            $setarr['tpl_name'] = $tpl_name;
            $setarr['username'] = $arr['username'];
            unset($arr['username']);
            $setarr['content'] = serialize($arr);
            $setarr['addtime'] = time();
            $query $this->db->add(table('notice'), $setarr);
            if ($query) {
                $insert_id $this->db->insert_id();
                curl::asynGET("index.php?m=ajax&a=notice_run&id=" $insert_id);
            }
        else {   return false; }
    }
    function notice_run($id) {
        $row $this->db->get_one("select * from " . table('notice') . " where status = 0 and id = " $id);
        if ($row['id']) {
            $arr = unserialize($row['content']);
            if ($row['type'] == 'sms') {
                $query $this->notice_sms($row['username'], $row['tpl_name'], $arr);
            elseif ($row['type'] == 'wxtpl') {
                $query $this->notice_wxtpl($row['username'], $row['tpl_name'], $arr);
            elseif ($row['type'] == 'email') {
                $query $this->notice_email($row['username'], $row['tpl_name'], $arr);
            }
            if ($query['error'] == '0') {
                $starr['status'] = '1';
                $query $this->db->update(table('notice'), $starr'id = ' $id);
                if ($query) {
                    return true;
                else {
                    return false;
                }
            else {
                $starr['status'] = '2';
                $starr['remark'] = $query['msg'];
                $query $this->db->update(table('notice'), $starr'id = ' $id);
                if ($query) {
                    return true;
                else {
                    return false;
                }
            }
        }
    }
    function notice_sms($mobile$tpl_name$arr) {
        $sms_row $this->sms_row();
        $wsql " and type = 'sms' and type2 = '" $sms_row['alias'] . "'";
        $an_row $this->db->get_one("select * from " . table("api_notice") . " where alias = '" $tpl_name "' limit 1");
        if ($an_row) {
            $tpl_row $this->db->get_one("select * from " . table("api_notice_tpl") . " where nid = '" $an_row['id'] . "' " . $wsql " limit 1");
        }
        $class_name 'sms_' $sms_row['alias'];
        $sms new $class_name($sms_row['app_key'], $sms_row['app_secret']);
        $aaa explode(','$tpl_row['param']);
        $aaa2 explode(','$tpl_row['param2']);
        foreach ($aaa2 as $kk => $vv) {$parr[$vv] = $arr[$aaa[$kk]];}
        if ($sms_row['sign'] == '' || $sms_row['app_key'] == '' || $sms_row['app_secret'] == '') {
            return array('error' => '1''msg' => $sms_row['alias'] . 'APP KEY, APP SECRET, SIGN簽名不能為空');
        else {
            if (isset($parr)) {
                if ($sms_row['alias'] == 'smsbao') {
                    $exec $sms->send($mobile,$parr,$tpl_row['content'],$sms_row['sign']);
                }else{
                $exec $sms->send($mobile$parr$tpl_row['tpl_id'], $sms_row['sign']);                    
                }
                if ($exec['error'] == '0') {
                    return array('error' => '0''msg' => '發(fā)送成功');
                else {
                    return array('error' => '1''msg' => $exec['msg']);
                }
            else {
                return array('error' => '1''msg' => '系統(tǒng)提交參數(shù)錯誤');
            }
        }
    }
    function notice_email($email$tpl_name$arr) {
        $wsql " and type = 'email'";
        $an_row $this->db->get_one("select * from " . table("api_notice") . " where alias = '" $tpl_name "' limit 1");
        if ($an_row) {
            $tpl_row $this->db->get_one("select * from " . table("api_notice_tpl") . " where nid = '" $an_row['id'] . "' " . $wsql " limit 1");
        }
        $aaa explode(','$tpl_row['param']);
        $aaa2 explode(','$tpl_row['param2']);
        $content $tpl_row['content'];
        foreach ($aaa2 as $kk => $vv) {
            $value = @$arr[$aaa[$kk]];
            $content str_replace('{' $vv '}'$value$content);
        }
        $query $this->email($email$tpl_row['name'], $content);
        if ($query) {
            return array('error' => '0''msg' => '發(fā)送成功');
        else {
            return array('error' => '1''msg' => '發(fā)送失敗');
        }
    }
    function notice_wxtpl($openid$tpl_name$arr) {
        $wsql " and type = 'wxtpl'";
        $an_row $this->db->get_one("select * from " . table("api_notice") . " where alias = '" $tpl_name "' limit 1");
        if ($an_row) {
            $tpl_row $this->db->get_one("select * from " . table("api_notice_tpl") . " where nid = '" $an_row['id'] . "' " . $wsql " limit 1");
        }
        $aaa explode(','$tpl_row['param']);
        $aaa2 explode(','$tpl_row['param2']);
        preg_match_all('#{([^}]*)#i'$tpl_row['content'], $matches);
        $aaaa $matches[1];
        foreach ($aaa2 as $kk => $vv) {
            $dat[$vv] = array('value' => isset($arr[$aaa[$kk]]) ? $arr[$aaa[$kk]] : $aaaa[$kk], 'color' => '#666666');
        }
        $data['touser'] = $openid;
        $data['url'] = $arr['link'];
        $data['template_id'] = $tpl_row['tpl_id'];
        $data['data'] = $dat;
        $url 'https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=' $this->module('login_wchat')->access_token();
        $postdata = (object)$data;
        $json_data = urldecode(json_encode($postdata));
        $result = curl::post($url$json_data);
        $result = json_decode($result);
        if ($result->errcode == '0') {
            return array('error' => '0''msg' => '發(fā)送成功');
        else {
            return array('error' => '1''msg' => $result->errmsg);
        }
    }
    function notice_list($tpl_name$cname) {
        $notice_name "config/api_notice_" $tpl_name;
        $cache_arr = cache::get($notice_name);
        if (!$cache_arr) {
            $row $this->db->get_one("select * from " . table('api_notice') . " where alias = '" $tpl_name "'");
            $query $this->db->get_all("select * from " . table('api_notice_tpl') . " where nid = " $row['id'] . " and type = " $cname " and status = 1");
            if ($query) {
                foreach ($query as $k => $v) {
                    $data[] = $v;
                }
                if ($data) {
                    cache::add($notice_name$data);
                else {
                    $data array();
                    cache::add($notice_name$data);
                }
                return $data;
            else {
                return false;
            }
        else {
            return $cache_arr;
        }
    }
    function sms_row() {
        $sms_name "config/api_sms";
        $cache_arr = cache::get($sms_name);
        if (!$cache_arr) {
            $sms_row $this->db->get_one("select * from " . table('api_sms') . " where status = 1");
            cache::add($sms_name$sms_row);
            return $sms_row;
        else {
            return $cache_arr;
        }
    }
    function login_list($arr) {
        $cache_arr = cache::get("config/api_login");
        if (!$cache_arr) {
            $cache_arr $this->db->get_all("select * from " . table('api_login') . " where status = 1");
            if ($cache_arr) {
                cache::add("config/api_login"$cache_arr);
            }
        }
        $user_status = isset($arr['user_status']) ? $arr['user_status'] : false;
        if ($user_status) {
            $row $this->db->get_one("select uid,qq_uid,weibo_uid,wchat_uid from " . table('member') . " where uid = " $this->uid);
            foreach ($cache_arr as $k => $v) {
                $apiname $v['alias'] . '_uid';
                if ($row[$apiname]) {
                    $v['bind_status'] = '1';
                }
                $data[] = $v;
            }
            return $data;
        else {
            return $cache_arr;
        }
    }
    function email($from_to$subject = null, $body = null, $attachment = null) {
        require UQCMS_PATH . 'UQframework/phpmailer/class.phpmailer.php';
        $mail new PHPMailer();
        $mail->CharSet = 'UTF-8';
        $mail->IsSMTP();
        $mail->SMTPDebug = 0;
        $mail->SMTPAuth = true;
        $mail->SMTPSecure = 'ssl';
        $mail->Host = cfg('email_host');
        $mail->Port = cfg('email_port');
        $mail->Username = cfg('email_username');
        $mail->Password = cfg('email_password');
        $mail->SetFrom(cfg('email_username'), cfg('email_name'));
        $mail->Subject = $subject;
        $mail->MsgHTML($body);
        $mail->AddAddress($from_to);
        if ($mail->Send()) {
            return true;
        else {
            return false;
        }
    }
    public function notice_type($str = null) {
        $arr array('wxtpl' => '微信模板''sms' => '短信通知''email' => '郵件通知',);
        if ($str) {
            return $arr[$str];
        else {
            return $arr;
        }
    }
}

接著打開項(xiàng)目\UQframework\core\common2.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
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
225
226
227
228
229
230
function error_404($msg) {
    header('HTTP/1.1 404 Not Found');
    header("status: 404 Not Found");
    $file_404 = UQCMS_PATH . 'public/404.html';
    if (file_exists($file_404)) {
        include $file_404;
    else {
        exit($msg);
    }
    exit;
}
function db() {
    static $dbconnect array();
    if (isset($dbconnect['db'])) {
        return $dbconnect['db'];
    else {
        $file = UQCMS_PATH . 'UQframework/core/db.class.php';
        if (file_exists($file)) {
            require ($file);
        }
        $db_cfg require_once UQCMS_PATH . 'data/dbconfig.php';
        $dbconnect['db'] = new dbi($db_cfg);
        $dbconnect['db']->conn();
        return $dbconnect['db'];
    }
}
function autoload($class) {
    $libs array('file_cache' => 'cache/file_cache''mem_cache' => 'cache/mem_cache''login_qq' => 'api/login_qq''login_weibo' => 'api/login_weibo''login_wchat' => 'api/login_wchat''oss_qiniu' => 'api/oss_qiniu''oss_aliyun' => 'api/oss_aliyun''oss_qcloud' => 'api/oss_qcloud''sms_aliyun' => 'api/sms_aliyun''sms_qcloud' => 'api/sms_qcloud''pay_alipay' => 'api/pay_alipay''pay_wxpay' => 'api/pay_wxpay''wchat' => 'api/wchat','sms_smsbao'=>'api/sms_smsbao');
    $file = UQCMS_PATH . 'UQframework' . DIRECTORY_SEPARATOR . 'class' . DIRECTORY_SEPARATOR . $class '.class.php';
    if (file_exists($file)) {
        include_once ($file);
    else {
        if (isset($libs[$class])) {
            $select_file = UQCMS_PATH . 'UQframework' . DIRECTORY_SEPARATOR . 'class' . DIRECTORY_SEPARATOR . $libs[$class] . '.class.php';
            if (file_exists($select_file)) {
                include_once ($select_file);
            else {
                error_404('autoload加載錯誤, ERROR:' $class);
            }
        else {
            error_404('autoload加載錯誤, ERROR:' $class);
        }
    }
}
function cfg($str = null) {
    static $cfg array();
    if (isset($cfg['cfg'])) {
        $cfg['cfg'] = $cfg['cfg'];
    else {
        $file = UQCMS_PATH . 'data' . DIRECTORY_SEPARATOR . 'site_configs.php';
        if (file_exists($file)) {
            $cfg['cfg'] = require_once $file;
        else {
            $cfglist = db()->get_all("select * from " . table('config'));
            if ($cfglist) {
                foreach ($cfglist as $k => $v) {
                    $cfg['cfg'][$v['name']] = $v['value'];
                }
            }
        }
        $develop_file = UQCMS_PATH . 'UQframework/core/development.php';
        if (file_exists($develop_file)) {
            $cfg require_once $develop_file;
        else {
            error_reporting(0);
            $cfg['cfg']['site_local'] = false;
        }
        $UQCMS_PATH str_replace('\\''/', UQCMS_PATH);
        $site_path substr($UQCMS_PATHstrlen($_SERVER['DOCUMENT_ROOT']), strlen($UQCMS_PATH));
        $site_path = ltrim($site_path'/');
        if ($site_path == '' || $site_path == '/') {
            $cfg['cfg']['site_path'] = '/';
            $cfg['cfg']['site_url'] = 'http://' $_SERVER['HTTP_HOST'] . '/';
        else {
            if (isset($cfg['cfg']['site_addr'])) {
                $cfg['cfg']['site_path'] = '/' $site_path;
                $cfg['cfg']['site_url'] = 'http://' $_SERVER['HTTP_HOST'] . '/' $site_path;
            else {
                $cfg['cfg']['site_path'] = '/';
                $cfg['cfg']['site_url'] = 'http://' $_SERVER['HTTP_HOST'] . '/';
            }
        }
        $request_addr $_SERVER['REQUEST_URI'];
        $request_url = urlencode('http://' $_SERVER['HTTP_HOST'] . $request_addr);
        $cfg['cfg']['request_url'] = $request_url;
        $user_agent $_SERVER['HTTP_USER_AGENT'];
        if (strpos($user_agent'MicroMessenger') === false) {
            if (is_mobile()) {
                $cfg['cfg']['browser'] = 'wap';
            else {
                $cfg['cfg']['browser'] = 'pc';
            }
        else {
            $cfg['cfg']['browser'] = 'wchat';
        }
    }
    if ($str == null) {
        return $cfg['cfg'];
    else {
        if (isset($cfg['cfg'][$str])) {
            return $cfg['cfg'][$str];
        else {
            return false;
        }
    }
}
function _browser_pid($position) {
    $pst array('pc' => '1''wap' => '2''wchat' => '3');
    if (isset($pst[$position])) {
        return $pst[$position];
    else {
        $bname = cfg('browser');
        return $pst[$bname];
    }
}
function mod($module_name) {
    static $mod_class array();
    if (isset($mod_class[$module_name])) {
        return $mod_class[$module_name];
    else {
        $file_mod = UQCMS_PATH . 'module/' $module_name ".mod.php";
        if (file_exists($file_mod)) {
            require_once ($file_mod);
            $modExt $module_name '_mod';
            $mod_class[$module_name] = new $modExt();
        else {
            echo '讀取的模塊不純在!';
        }
    }
    return $mod_class[$module_name];
}
function error_json($msg$name = null) {
    if (!empty($name)) {
        $arr array('error' => '1''msg' => $msg'name' => $name);
    else {
        $arr array('error' => '1''msg' => $msg);
    }
    $arrjson = json_encode($arr);
    exit($arrjson);
}
function right_json($arr1 array()) {
    $arr2 array('error' => '0');
    if (!empty($arr1)) {
        $arr array_merge($arr1$arr2);
    else {
        $arr $arr2;
    }
    $arrjson = json_encode($arr);
    exit($arrjson);
}
function sys_log($msg) {
    file_put_contents(UQCMS_PATH . 'temp/log/sys.txt'$msg . PHP_EOL, FILE_APPEND);
}
function db_log($sql) {
    file_put_contents(UQCMS_PATH . 'temp/log/mysql.txt'$sql . PHP_EOL, FILE_APPEND);
}
function img_host() {
    if (isset($imgArr)) {
        return $imgArr;
    else {
        $file = UQCMS_PATH . 'temp/config/imgHost.php';
        if (file_exists($file)) {
            $imgArr require_once $file;
        else {
            $imgArr = img_config();
        }
        return $imgArr['host'];
    }
}
function img_size($size$string = null) {
    if (isset($string_link[$size])) {
        return $string_link[$size];
    else {
        $imgArr = img_config();
        if ($imgArr['alias'] == '') {
            if ($string) {
                return $string_link[$size] = $string;
            else {
                return $string_link[$size] = '';
            }
        else {
            $sizeArr explode('x'$size);
            $ossname 'oss_' $imgArr['alias'];
            $conn_link $ossname::img_size($sizeArr[0], $sizeArr[1]);
            if ($string) {
                return $string_link[$size] = $string $conn_link;
            else {
                return $string_link[$size] = $conn_link;
            }
        }
    }
}
function img_config() {
    $file = UQCMS_PATH . 'temp/config/imgOss.php';
    if (file_exists($file)) {
        $imgArr include $file;
    else {
        $row = db()->get_one("select id,alias,host from " . table('api_oss') . " where status = 1");
        if ($row['host']) {
            $imgArr['alias'] = $row['alias'];
            $imgArr['host'] = '//' $row['host'] . '/';
        else {
            $imgArr['alias'] = '';
            $imgArr['host'] = '';
        }
        file_put_contents('temp/config/imgOss.php'"<?php \r\n return " . var_export($imgArr, true) . ";");
    }
    return $imgArr;
}
function P($name$msg ''$default_value '') {
    if ($msg === false || $msg === 0) {
        return !empty($_POST[$name]) ? trim($_POST[$name]) : false;
    else {
        if ($default_value || $default_value == '0') {
            return !empty($_POST[$name]) ? trim($_POST[$name]) : $default_value;
        else {
            if (empty($msg)) {
                return !empty($_POST[$name]) ? trim($_POST[$name]) : '';
            else {
                return !empty($_POST[$name]) ? trim($_POST[$name]) : error_json($msg$name);
            }
        }
    }
}
function _date($time) {
    if ($time == '0' || $time == '') {
    else {
        return date('Y-m-d H:s'$time);
    }
}

最后我們在項(xiàng)目\UQframework\class\api\下創(chuàng)建sms_smsbao.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
<?php
 
class sms_smsbao extends module
{
 
 function __construct($app_id,$app_key)
 {
  $this->app_id = $app_id;
  $this->app_key = $app_key;
  $this->url = 'http://api.smsbao.com/sms?';
 }
 
 function send($mobile,$param_arr,$content,$sign=null)
 {
 
  foreach ($param_arr as $key => $value) {
   $content str_replace("{".$key."}"$value$content);
  }
  $contents "【".$sign."】".$content
  
  $url $this->url.'u='.$this->app_id.'&p='.md5($this->app_key).'&m='.$mobile.'&c='.$contents;
 
 
        if (function_exists('file_get_contents')) {
            $ret file_get_contents($url);
        }else{
            $ch = curl_init();
            $timeout = 5;
            curl_setopt($ch, CURLOPT_URL, $url);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
            $ret = curl_exec($ch);
            curl_close($ch);
        }
 
        if ($ret == 0) {
         $result_info['error'] = '0';
         $result_info['msg'] = '發(fā)送成功';
         return $result_info;
        }else{
         $result_info['error'] = '1';
         $result_info['msg'] = $ret;
         return $result_info;
        }
 
 
 
 }
 
 
 private static $instance;
    public static function init() {
        if (is_null(self::$instance)) {
            self::$instance new self();
        }
        return self::$instance;
    }
}

好了,經(jīng)過以上的替換,短信寶的短信平臺已經(jīng)替換成功了,可以正常使用了。我們進(jìn)行測試發(fā)送。

報備一下短信寶的VIP模板,這樣就可以走短信寶的優(yōu)質(zhì)通道了,即便遇到敏感文字我們都不會人工審核,短信內(nèi)容3~5秒就可送達(dá)。

另外:我們已經(jīng)開發(fā)好完整的UQCMS云商系統(tǒng)短信寶插件,點(diǎn)擊此鏈接 下載及查看安裝流程。

開源插件

最新更新

電商類

CMS類

微信類

文章標(biāo)簽