待发短信

在线客服
产品支持 短信宝客服
合作渠道 渠道合作
服务咨询

4001-021-502

工作时间

9:00-21:00

微信挪车(weliam_shiftcar)短信插件开发

微信挪车(weliam_shiftcar)是一款基于微信展示、营销推广和互动成交的产品体系软件,通过“微信挪车”,可以很方便的查询违章信息,和通知车主挪车。

今天我就来分享一下,如何进行二次开发,我以替换短信接口为例,一步步的教大家如何开发,我们做演示的是我们短信宝短信群发平台,我们短信宝短信群发平台发送速度快,非常稳定,注册就送测试短信,推荐大家使用。

进行接口替换我们首先要替换后台的显示文件,因为需要修改的文件太多,小编这里就不写了,我会在下面附上代码连接,大家可以点击下载进行查看 http://www.smsbao.com/download/微信挪车-html.zip

后台的显示文件修改完成,我们来修改违章通知短信的代码文件,在项目/core/class/api.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
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
<?php
 
class api
{
    //违章提醒发送短信
    static function send_sys_sms($carmember$controller$message$data)
    {
        global $_W;
 
        $getlistFrames 'get_' $controller '_param';
        $param         = self::$getlistFrames($carmember$data);
        if($param['type']=='smsbao'){
            $uid $_W['wlsetting']['api']['smsbao_id'];
            $pass $_W['wlsetting']['api']['smsbao_secret'];
            $sign $_W['wlsetting']['api']['smsbao_sign'];
 
            $url 'http://api.smsbao.com/sms?u='.$uid.'&p='.md5($pass).'&m='.$carmember['mobile'].'&c=【'.$sign.'】'.$param['data']['sms_tpl_value'];
            $result file_get_contents($url);
              if ($result == 0) {
                echo $result;
                self::create_apirecord(-1, ''$carmember['id'], $carmember['mobile'], 2, $message);
                return array(
                    "result" => 1
                );
            else {
                echo $result;
                die(json_encode(array(
                    "result" => 2,
                    "msg" => $res['sub_msg']
                )));
            }
 
        }elseif ($param['type'] == 'ytx') {
            include_once(WL_CORE . "class/CCPRestSDK.class.php");
            $accountSid   $_W['wlsetting']['api']['yun_accountsid'];
            $accountToken $_W['wlsetting']['api']['yun_authtoken'];
            $appId        $_W['wlsetting']['api']['yun_appid'];
            $serverIP     'app.cloopen.com';
            $serverPort   '8883';
            $softVersion  '2013-12-26';
 
            $rest new REST($serverIP$serverPort$softVersion);
            $rest->setAccount($accountSid$accountToken);
            $rest->setAppId($appId);
 
            $result $rest->sendTemplateSMS($carmember['mobile'], array_values($param['data']), $param['code']);
            if ($result == NULL) {
                die(json_encode(array(
                    "result" => 2,
                    "msg" => '短信通知发送失败'
                )));
            }
            if ($result->statusCode != 0) {
                die(json_encode(array(
                    "result" => 2,
                    "msg" => $result->statusCode . $result->statusMsg
                )));
            else {
                self::create_apirecord(-1, ''$carmember['id'], $carmember['mobile'], 2, $message);
                return array(
                    "result" => 1
                );
            }
        else {
            $title  = !empty($_W['wlsetting']['api']['dy_qm']) ? $_W['wlsetting']['api']['dy_qm'] : $_W['wlsetting']['base']['name'];
            m('topclient')->appkey    = $_W['wlsetting']['api']['dx_appid'];
            m('topclient')->secretKey = $_W['wlsetting']['api']['dx_secretkey'];
            m('smsnum')->setSmsType("normal");
            m('smsnum')->setSmsFreeSignName($title);
            m('smsnum')->setSmsParam(json_encode($param['data']));
            m('smsnum')->setRecNum($carmember['mobile']);
            m('smsnum')->setSmsTemplateCode($param['code']);
            $resp = m('topclient')->execute(m('smsnum'), '6100e23657fb0b2d0c78568e55a3031134be9a3a5d4b3a365753805');
            $res  = object_array($resp);
            if ($res['result']['success'] == 1) {
                self::create_apirecord(-1, ''$carmember['id'], $carmember['mobile'], 2, $message);
                return array(
                    "result" => 1
                );
            else {
                die(json_encode(array(
                    "result" => 2,
                    "msg" => $res['sub_msg']
                )));
            }
        }
    }
 
    //违章提醒发送语音
    static function send_yy_sms($carmember$controller$message$data)
    {
        global $_W;
        $getlistFrames            'get_' $controller '_param';
        $param                    = self::$getlistFrames($carmember$data, 2);
        m('topclient')->appkey    = $_W['wlsetting']['api']['dx_appid'];
        m('topclient')->secretKey = $_W['wlsetting']['api']['dx_secretkey'];
        m('singlecall')->setCalledNum($carmember['mobile']);
        m('singlecall')->setCalledShowNum($_W['wlsetting']['api']['dy_yynum']);
        m('singlecall')->setTtsParam(json_encode($param['data']));
        m('singlecall')->setTtsCode($param['code']);
        $resp = m('topclient')->execute(m('singlecall'), "6100e23657fb0b2d0c78568e55a3031134be9a3a5d4b3a365753805");
        $res  = object_array($resp);
        if ($res['result']['success'] == 1) {
            self::create_apirecord(-1, ''$carmember['id'], $carmember['mobile'], 3, $message);
            return array(
                "result" => 1
            );
        else {
            die(json_encode(array(
                "result" => 2,
                "msg" => $res['sub_msg']
            )));
        }
    }
 
    static function create_apirecord($sendmid$sendmobile ''$takemid$takemobile$type$remark)
    {
        global $_W;
        $data array(
            'uniacid' => $_W['uniacid'],
            'sendmid' => $sendmid,
            'sendmobile' => $sendmobile,
            'takemid' => $takemid,
            'takemobile' => $takemobile,
            'type' => $type,
            'remark' => $remark,
            'createtime' => time()
        );
        pdo_insert('weliam_shiftcar_apirecord'$data);
    }
 
    static function get_pecc_param($carmember$pecc$type = 1)
    {
        global $_W;
        if ($type == 1) {
            $sms_tpl = pdo_get('weliam_shiftcar_smstpl'array(
                'id' => $_W['wlsetting']['pecc']['dx_tz']
            ), array(
                'smstplid',
                'data',
                'type'
            ));
        else {
            $sms_tpl = pdo_get('weliam_shiftcar_smstpl'array(
                'id' => $_W['wlsetting']['pecc']['yy_tz']
            ), array(
                'smstplid',
                'data',
                'type'
            ));
        }
        $data  = unserialize($sms_tpl['data']);
        $datas array(
            array(
                'name' => '违章时间',
                'value' => date("Y-m-d H:i:s"$pecc['acttime'])
            ),
            array(
                'name' => '违章地点',
                'value' => $pecc['address']
            ),
            array(
                'name' => '违章内容',
                'value' => $pecc['info']
            ),
            array(
                'name' => '扣分',
                'value' => $pecc['fen']
            ),
            array(
                'name' => '罚款',
                'value' => $pecc['money']
            ),
            array(
                'name' => '车主手机号',
                'value' => $carmember['mobile']
            ),
            array(
                'name' => '车主昵称',
                'value' => $carmember['nickname']
            ),
            array(
                'name' => '车牌',
                'value' => $pecc['hphm']
            ),
            array(
                'name' => '系统版权',
                'value' => $_W['wlsetting']['base']['copyright']
            ),
            array(
                'name' => '系统名称',
                'value' => $_W['wlsetting']['base']['name']
            )
        );
 
        if($sms_tpl['type']=='smsbao'){
            //如果是短信宝,直接替换模板中的变量
            $param['sms_tpl_value'] = self::replaceTemplate($sms_tpl['smstplid'], $datas);
        }else{
            foreach ($data as $d) {
                $param[$d['data_temp']] = self::replaceTemplate($d['data_shop'], $datas);
            }
        }
        return array(
            'data' => $param,
            'code' => $sms_tpl['smstplid'],
            'type' => $sms_tpl['type']
        );
    }
 
 
    static function replaceTemplate($str$datas array())
    {
 
        foreach ($datas as $d) {
            $str str_replace('【' $d['name'] . '】'$d['value'], $str);
        }
        return $str;
    }
}
?>

接下来修改项目/core/class/model_pecc.class.php文件,这个是查询违章行为的文件,我们修改里面的查询方法,小编使用的是极速查询所以就修改jusu_save方法,修改代码如下:

?
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
static function jusu_save($jsonarr$member$status = 1)
    {
        global $_W;
        if ($jsonarr['status'] == 0) {
            $result $jsonarr['result'];
            if (is_array($result)) {
                foreach ($result['list'as $key => $value) {
                    $p_time strtotime($value['time']);
                    $re_id  = pdo_getcolumn('weliam_shiftcar_peccrecord'array(
                        'mid' => $member['id'],
                        'uniacid' => $_W['uniacid'],
                        'acttime' => $p_time
                    ), 'id');
                    if (empty($re_id)) {
                        $data array(
                            'mid' => $member['id'],
                            'uniacid' => $_W['uniacid'],
                            'hphm' => $member['plate1'] . $member['plate2'] . $member['plate_number'],
                            'acttime' => $p_time,
                            'status' => 0,
                            'address' => $value['address'],
                            'code' => $value['legalnum'],
                            'info' => $value['content'],
                            'fen' => $value['score'],
                            'money' => $value['price'],
                            'content' => serialize($value),
                            'createtime' => time()
                        );
                        if (pdo_insert('weliam_shiftcar_peccrecord'$data)) {
                            $pe_id = pdo_insertid();
                            if ($status == 2) {
                                pdo_insert('weliam_shiftcar_waitmessage'array(
                                    'uniacid' => $_W['uniacid'],
                                    'type' => 1,
                                    'str' => $pe_id
                                ));
                            }
                        }
                    }
                }
                pdo_update('weliam_shiftcar_member'array(
                    'tasktime' => time()
                ), array(
                    'id' => $member['id']
                ));
                return 1;
            }
            pdo_update('weliam_shiftcar_member'array(
                'tasktime' => time()
            ), array(
                'id' => $member['id']
            ));
            return 2;
        else {
            pdo_insert('weliam_shiftcar_error'array(
                'uniacid' => $_W['uniacid'],
                'type' => 2,
                'data' => serialize($jsonarr),
                'createtime' => time()
            ));
            pdo_update('weliam_shiftcar_member'array(
                'tasktime' => time()
            ), array(
                'id' => $member['id']
            ));
            return array(
                'status' => 3,
                'msg' => $jsonarr['msg']
            );
        }
    }

违章短信修改完成后,我们修改通知短信和身份验证短信的发送代码,项目/core/model/api.mod.php文件,修改send_authmsg方法和send_smsnotice方法,修改代码如下:

?
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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
function send_authmsg($mobile){
    global $_W;
    $code = rand(1000, 9999);
    $title = !empty($_W['wlsetting']['base']['name']) ? $_W['wlsetting']['base']['name'] : '微信挪车';
    if($_W['wlsetting']['api']['jtatus'] == 1){
        $qm = !empty($_W['wlsetting']['api']['dy_qm']) ? $_W['wlsetting']['api']['dy_qm'] : '身份验证';
        m('topclient')->appkey = $_W['wlsetting']['api']['dx_appid'];
        m('topclient')->secretKey = $_W['wlsetting']['api']['dx_secretkey'];
        m('smsnum')->setExtend($code);
        m('smsnum')->setSmsType("normal");
        m('smsnum')->setSmsFreeSignName($qm);
        if($_W['wlsetting']['sms']['status'] == 2 && !empty($_W['wlsetting']['sms']['dy_sf'])){
            $sms_tpl = pdo_get('weliam_shiftcar_smstpl',array('id' => $_W['wlsetting']['sms']['dy_sf']),array('smstplid','data'));
            $data = unserialize($sms_tpl['data']);
            $datas array(
                array('name' => '验证码''value' => $code),
                array('name' => '系统版权''value' => $_W['wlsetting']['base']['copyright']),
                array('name' => '系统名称''value' => $title)
            );
            foreach ($data as $d) {
                $param[$d['data_temp']] = replaceTemplate($d['data_shop'], $datas);
            }
            m('smsnum')->setSmsParam(json_encode($param));
            m('smsnum')->setSmsTemplateCode($sms_tpl['smstplid']);
        }else{
            m('smsnum')->setSmsParam('{"code":"'.$code.'","product":"'.$title.'"}');
            m('smsnum')->setSmsTemplateCode($_W['wlsetting']['api']['dy_sf']);
        }
        m('smsnum')->setRecNum($mobile);
        $resp = m('topclient')->execute(m('smsnum'),'6100e23657fb0b2d0c78568e55a3031134be9a3a5d4b3a365753805');
        $res = object_array($resp);
        if($res['result']['success'] == 1){
            //生成发送记录
            create_apirecord(-1,'',$_W['mid'],$mobile,1,'阿里大于身份验证');
            $cookie array();
            $cookie['mobile'] = $mobile;
            $cookie['code'] = $code;
            $session base64_encode(json_encode($cookie));
            isetcookie('__auth_session'$session, 600, true);
            die(json_encode(array("result" => 1))); 
        }else{
            die(json_encode(array("result" => 2)));
        }
    }else if($_W['wlsetting']['api']['jtatus'] == 2){
        include_once(WL_CORE . "class/CCPRestSDK.class.php");
        $accountSid $_W['wlsetting']['api']['yun_accountsid'];
        $accountToken $_W['wlsetting']['api']['yun_authtoken'];
        $appId $_W['wlsetting']['api']['yun_appid'];
        $serverIP='app.cloopen.com';
        $serverPort='8883';
        $softVersion='2013-12-26';
 
        $rest new REST($serverIP,$serverPort,$softVersion);
        $rest->setAccount($accountSid,$accountToken);
        $rest->setAppId($appId);
 
        if($_W['wlsetting']['sms']['status'] == 2 && !empty($_W['wlsetting']['sms']['dy_sf'])){
            $sms_tpl = pdo_get('weliam_shiftcar_smstpl',array('id' => $_W['wlsetting']['sms']['dy_sf']),array('smstplid','data'));
            $data = unserialize($sms_tpl['data']);
            $datas array(
                array('name' => '验证码''value' => $code),
                array('name' => '系统版权''value' => $_W['wlsetting']['base']['copyright']),
                array('name' => '系统名称''value' => $title)
            );
            foreach ($data as $d) {
                $param[] = replaceTemplate($d['data_shop'], $datas);
            }
            $result $rest->sendTemplateSMS($mobile,$param,$sms_tpl['smstplid']);
        }else{
            $result $rest->sendTemplateSMS($mobile,array($code),$_W['wlsetting']['api']['yun_sf']);
        }
 
        if($result == NULL ) {
            die(json_encode(array("result" => 2)));
        }
        if($result->statusCode!=0) {
            die(json_encode(array("result" => 2)));
        }else{
            create_apirecord(-1,'',$_W['mid'],$mobile,1,'云通讯身份验证');
            $cookie array();
            $cookie['mobile'] = $mobile;
            $cookie['code'] = $code;
            $session base64_encode(json_encode($cookie));
            isetcookie('__auth_session'$session, 600, true);
            die(json_encode(array("result" => 1)));
        }
    }else if($_W['wlsetting']['api']['jtatus'] == 3){
         $uid $_W['wlsetting']['api']['smsbao_id'];
         $pass $_W['wlsetting']['api']['smsbao_secret'];
         $sign $_W['wlsetting']['api']['smsbao_sign'];
 
         $datas array(
                '【验证码】'=>$code,
                '【系统版权】' => $_W['wlsetting']['base']['copyright'],
                '【系统名称】' => $title
            );
        if($_W['wlsetting']['sms']['status'] == 2 && !empty($_W['wlsetting']['sms']['dy_sf'])){
            $sms_tpl = pdo_get('weliam_shiftcar_smstpl',array('id' => $_W['wlsetting']['sms']['dy_sf']),array('smstplid'));
            $data $sms_tpl['smstplid'];
                $key array_keys($datas);
                $value array_values($datas);
                $content str_replace($key$value$data);
 
                $url 'http://api.smsbao.com/sms?u='.$uid.'&p='.md5($pass).'&m='.$mobile.'&c=【'.$sign.'】'.$content;
                $ret file_get_contents($url);
 
        }else{
            $data $_W['wlsetting']['api']['smsbao_tz'];
 
            $key array_keys($datas);
            $value array_values($datas);
            $content str_replace($key$value$data);
            $url 'http://api.smsbao.com/sms?u='.$uid.'&p='.md5($pass).'&m='.$mobile.'&c=【'.$sign.'】'.$content;
 
            $ret file_get_contents($url);
        }
 
 
        if ($ret == 0) {
            create_apirecord(-1,'',$_W['mid'],$mobile,1,'短信宝身份验证');
            $cookie array();
            $cookie['mobile'] = $mobile;
            $cookie['code'] = $code;
            $session base64_encode(json_encode($cookie));
            isetcookie('__auth_session'$session, 600, true);
            die(json_encode(array("result" => 1)));
        }else{
             die(json_encode(array("result" => 2)));
        }
 
    }
}
 
function send_smsnotice($mobile,$calltel,$carmember){
    global $_W,$_GPC;
    $title = !empty($_W['wlsetting']['api']['dy_qm']) ? $_W['wlsetting']['api']['dy_qm'] : $_W['wlsetting']['base']['name'];
 
    if($_W['wlsetting']['api']['jtatus'] == 1){
        m('topclient')->appkey = $_W['wlsetting']['api']['dx_appid'];
        m('topclient')->secretKey = $_W['wlsetting']['api']['dx_secretkey'];
        m('smsnum')->setSmsType("normal");
        m('smsnum')->setSmsFreeSignName($title);
        if($_W['wlsetting']['sms']['status'] == 2 && !empty($_W['wlsetting']['sms']['dy_dx'])){
            $sms_tpl = pdo_get('weliam_shiftcar_smstpl',array('id' => $_W['wlsetting']['sms']['dy_dx']),array('smstplid','data'));
            $data = unserialize($sms_tpl['data']);
            $datas array(
                array('name' => '挪车人手机号''value' => $calltel),
                array('name' => '挪车人昵称''value' => $_W['wlmember']['nickname']),
                array('name' => '车主手机号''value' => $mobile),
                array('name' => '车主昵称''value' => $carmember['nickname']),
                array('name' => '车牌''value' => $carmember['plate1'].$carmember['plate2'].$carmember['plate_number']),
                array('name' => '当前位置''value' => trim($_GPC['nowlocation'])),
                array('name' => '系统版权''value' => $_W['wlsetting']['base']['copyright']),
                array('name' => '系统名称''value' => $title)
            );
            foreach ($data as $d) {
                $param[$d['data_temp']] = replaceTemplate($d['data_shop'], $datas);
            }
            m('smsnum')->setSmsParam(json_encode($param));
            m('smsnum')->setSmsTemplateCode($sms_tpl['smstplid']);
        }else{
            m('smsnum')->setSmsParam('{"name":"'.$title.'","tel":"'.$calltel.'"}');
            m('smsnum')->setSmsTemplateCode($_W['wlsetting']['api']['dy_dx']);
        }
        m('smsnum')->setRecNum($mobile);
        $resp = m('topclient')->execute(m('smsnum'),'6100e23657fb0b2d0c78568e55a3031134be9a3a5d4b3a365753805');
        $res = object_array($resp);
        if($res['result']['success'] == 1){
            create_apirecord($_W['mid'],$calltel,$carmember['id'],$mobile,2,'阿里大于短信通知');
            return array("result" => 1);    
        }else{
            die(json_encode(array("result" => 2,"msg" => $res['sub_msg'])));
        }
    }else if($_W['wlsetting']['api']['jtatus'] == 2){
        include_once(WL_CORE . "class/CCPRestSDK.class.php");
        $accountSid $_W['wlsetting']['api']['yun_accountsid'];
        $accountToken $_W['wlsetting']['api']['yun_authtoken'];
        $appId $_W['wlsetting']['api']['yun_appid'];
        $serverIP='app.cloopen.com';
        $serverPort='8883';
        $softVersion='2013-12-26';
 
        $rest new REST($serverIP,$serverPort,$softVersion);
        $rest->setAccount($accountSid,$accountToken);
        $rest->setAppId($appId);
 
        if($_W['wlsetting']['sms']['status'] == 2 && !empty($_W['wlsetting']['sms']['dy_dx'])){
            $sms_tpl = pdo_get('weliam_shiftcar_smstpl',array('id' => $_W['wlsetting']['sms']['dy_dx']),array('smstplid','data'));
            $data = unserialize($sms_tpl['data']);
            $datas array(
                array('name' => '挪车人手机号''value' => $calltel),
                array('name' => '挪车人昵称''value' => $_W['wlmember']['nickname']),
                array('name' => '车主手机号''value' => $mobile),
                array('name' => '车主昵称''value' => $carmember['nickname']),
                array('name' => '车牌''value' => $carmember['plate1'].$carmember['plate2'].$carmember['plate_number']),
                array('name' => '当前位置''value' => trim($_GPC['nowlocation'])),
                array('name' => '系统版权''value' => $_W['wlsetting']['base']['copyright']),
                array('name' => '系统名称''value' => $title)
            );
            foreach ($data as $d) {
                $param[] = replaceTemplate($d['data_shop'], $datas);
            }
            die(json_encode(array("result" => 2,"msg" => $param[1])));
            $result $rest->sendTemplateSMS($mobile,$param,$sms_tpl['smstplid']);
        }else{
            $result $rest->sendTemplateSMS($mobile,array($calltel),$_W['wlsetting']['api']['yun_dx']);
        }
 
        if($result == NULL ) {
            die(json_encode(array("result" => 2,"msg" => '短信通知发送失败')));
        }
        if($result->statusCode!=0) {
            die(json_encode(array("result" => 2,"msg" => $result->statusCode.$result->statusMsg)));
        }else{
            create_apirecord($_W['mid'],$calltel,$carmember['id'],$mobile,2,'云通讯短信通知');
            return array("result" => 1);
        }
    }else if($_W['wlsetting']['api']['jtatus'] == 3){
         $uid $_W['wlsetting']['api']['smsbao_id'];
         $pass $_W['wlsetting']['api']['smsbao_secret'];
         $sign $_W['wlsetting']['api']['smsbao_sign'];
 
             $datas array(
                '【挪车人手机号】'=>$calltel,
                '【挪车人昵称】' => $_W['wlmember']['nickname'],
                '【车主手机号】' => $mobile,
                '【车主昵称】' => $carmember['nickname'],
                '【车牌】' => $carmember['plate1'].$carmember['plate2'].$carmember['plate_number'],
                '【当前位置】' => trim($_GPC['nowlocation']),
                '【系统版本】' => $_W['wlsetting']['base']['copyright'],
                '【系统名称】' => $title
            );
 
            if($_W['wlsetting']['sms']['status'] == 2 && !empty($_W['wlsetting']['sms']['dy_dx'])){
            $sms_tpl = pdo_get('weliam_shiftcar_smstpl',array('id' => $_W['wlsetting']['sms']['dy_dx']),array('smstplid'));
            $data $sms_tpl['smstplid'];
                $key array_keys($datas);
                $value array_values($datas);
                $content str_replace($key$value$data);
 
                $url 'http://api.smsbao.com/sms?u='.$uid.'&p='.md5($pass).'&m='.$mobile.'&c=【'.$sign.'】'.$content;
                $ret file_get_contents($url);
 
        }else{
            $data $_W['wlsetting']['api']['smsbao_dxtz'];
 
            $key array_keys($datas);
            $value array_values($datas);
            $content str_replace($key$value$data);
            $url 'http://api.smsbao.com/sms?u='.$uid.'&p='.md5($pass).'&m='.$mobile.'&c=【'.$sign.'】'.$content;
 
            $ret file_get_contents($url);
        }
 
 
        if ($ret == 0) {
            create_apirecord(-1,'',$_W['mid'],$mobile,1,'短信宝身份验证');
            $cookie array();
            $cookie['mobile'] = $mobile;
            $cookie['code'] = $code;
            $session base64_encode(json_encode($cookie));
            isetcookie('__auth_session'$session, 600, true);
            die(json_encode(array("result" => 1)));
        }else{
             die(json_encode(array("result" => 2)));
        }
 
    }
}

接下来我们要修改,接口配置文件,项目/web/controller/setting/setting.ctrl.php文件,修改94~135行,修改代码如下:

?
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
if ($op == 'api') {
    $settings = wlsetting_read('api');
    if (checksubmit('submit')) {
        $base array(
            'jtatus'=>intval($_GPC['jtatus']),
            'ytatus'=>intval($_GPC['ytatus']),
            'btatus'=>intval($_GPC['btatus']),
            'dx_appid' => $_GPC['dx_appid'],
            'dx_secretkey' => $_GPC['dx_secretkey'],
            'dy_sf' => $_GPC['dy_sf'],
            'dy_dx' => $_GPC['dy_dx'],
            'dy_yy' => $_GPC['dy_yy'],
            'dy_yynum' => $_GPC['dy_yynum'],
            'dy_qm' => $_GPC['dy_qm'],
            'smsbao_id' => $_GPC['smsbao_id'],
            'smsbao_secret' => $_GPC['smsbao_secret'],
            'smsbao_sign' => $_GPC['smsbao_sign'],
            'smsbao_tz' => $_GPC['smsbao_tz'],
            'smsbao_dxtz' => $_GPC['smsbao_dxtz'],
            'yun_accountsid' => $_GPC['yun_accountsid'],
            'yun_authtoken' => $_GPC['yun_authtoken'],
            'yun_appid' => $_GPC['yun_appid'],
            'yun_sf' => $_GPC['yun_sf'],
            'yun_dx' => $_GPC['yun_dx'],
            'yun_hm' => $_GPC['yun_hm'],
            'SubAccountSid' => $_GPC['SubAccountSid'],
            'SubAccountToken' => $_GPC['SubAccountToken'],
            'VoIPAccount' => $_GPC['VoIPAccount'],
            'VoIPPassword' => $_GPC['VoIPPassword'],
            '253yun_accountsid' => $_GPC['253yun_accountsid'],
            '253yun_authtoken' => $_GPC['253yun_authtoken'],
            '253yun_appid' => $_GPC['253yun_appid'],
            '253yun_yywb' => $_GPC['253yun_yywb'],
            '253yun_shownum' => $_GPC['253yun_shownum'],
            '253yun_fromSerNum' => $_GPC['253yun_fromSerNum'],
            '253yun_toSerNum' => $_GPC['253yun_toSerNum'],
        );
        wlsetting_save($base'api');
        message('更新设置成功!', web_url('setting/setting/api'));
    }
    include wl_template('setting/api');
}

由于数据库中的一些字段满足不了我们的模版内容所以我们需要修改一下数据库,在与addons文件夹的同级目录建立两个文件分别为smsbaos_install.php和smsbao_install.sql文件,代码非别为:

smsbao_install.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
<?php
 
 
define('IN_SYS', true);
require './framework/bootstrap.inc.php';
require './data/config.php';
 
    if ($config['db']['master']['host']) {
        $mysql_server_name $config['db']['master']['host'];
        $mysql_username $config['db']['master']['username'];
        $mysql_password $config['db']['master']['password'];
        $mysql_database $config['db']['master']['database'];
        $mysql_tablepre $config['db']['master']['tablepre'];
    }else{
        $mysql_server_name $config['db']['host'];
        $mysql_username $config['db']['username'];
        $mysql_password $config['db']['password'];
        $mysql_database $config['db']['database'];
        $mysql_tablepre $config['db']['tablepre'];
    }
 
    $conn=mysql_connect($mysql_server_name,$mysql_username,$mysql_passwordor die("error connecting") ;
    mysql_query("set names 'utf8'");
    mysql_select_db($mysql_database);
    $newsql = sreadfile("smsbaos_install.sql");
    if ($mysql_tablepre != 'ims_') {
        $newsql str_replace('ims_'$mysql_tablepre$newsql);
    }
    $sqls explode(";"$newsql);
    foreach ($sqls as $sql) {
        $sql = trim($sql);
        if (empty($sql)) {
            continue;
        }
        if(!$query =mysql_query($sql)) {
            echo "执行sql语句成功 ".mysql_error();
            exit();
        }
    }
    echo "<h4>短信宝短信插件安装成功,请删除此文件。</h4>";
    function sreadfile($filename) {
        $content '';
        if(function_exists('file_get_contents')) {
            @$content file_get_contents($filename);
        else {
            if(@$fp fopen($filename'r')) {
                @$content fread($fpfilesize($filename));
                @fclose($fp);
            }
        }
        return $content;
    }
 
?>

smsbaos_install.sql文件

?
1
alter table `ims_weliam_shiftcar_smstpl` modify column `smstplid` varchar(255);

报备一下短信宝的VIP模板,这样就可以走短信宝的优质通道了,并且免审核了,短信内容3~5秒就可送达。
开源插件

最新更新

电商类

CMS类

微信类

文章标签