待发短信

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

4001-021-502

工作时间

9:00-18:00

MetInfoV7.2.0新增短信宝短信接口

米拓企业建站系统MetInfo主要用于搭建企业网站,采用PHP+MySQL架构,支持SQLite数据库,全站内置了SEO搜索引擎优化机制,支持用户自定义语言(全球各种语言),支持可视化编辑管理。小编对这款系统还比较了解,今天就以替换短信接口为例为大家讲解一下如何进行二次开发,使用的短信接口是我们短信宝短信群发平头的短信接口,我们短信宝短信群发平台非常稳定,发送速度快,注册就送测试短信,推荐大家使用。

1:打开项目:\app\app\met_sms\admin\templates\index.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
 <div class="metadmin-fmbx">
                        <dl>
                            <dt>
                                <label class='form-control-label'>短信宝账号</label>
                            </dt>
                            <dd>
                                <div class='form-group clearfix'>
                                    <input type="text" name="met_sms_user" class="form-control" value="{$_M['config']['met_sms_user']}">
                                    <if value="$c.met_agents_metmsg eq '1'">
                                        <a href="https://smsbao.com/reg" target="_blank" class="ml-3" style="line-height:35px;color: red">还没有账号?点击注册</a>
                                    </if>
                                </div>
                            </dd>
                        </dl>
 
 
                        <dl>
                            <dt>
                                <label class='form-control-label'>短信宝密码</label>
                            </dt>
                            <dd>
                                <div class='form-group clearfix'>
                                    <input type="text" name="met_sms_token" class="form-control" value="{$_M['config']['met_sms_token']}">
 
 
                                </div>
                            </dd>
                        </dl>
 
 
                        <dl>
                            <dt>
                                <label class='form-control-label'>短信宝签名</label>
                            </dt>
                            <dd>
                                <div class='form-group clearfix'>
                                    <input type="text" name="met_sms_sing" class="form-control" value="{$_M['config']['met_sms_sing']}">
                                </div>
                            </dd>
                        </dl>
 
 
                        <dl>
                            <dt></dt>
                            <dd>
                                <button type="submit" class='btn btn-primary'>{$word.save}</button>
                            </dd>
                        </dl>
                    </div>

2:打开项目:\app\app\met_sms\admin\index.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
public function dosave()
    {
        global $_M;
        $token = $_M['form']['met_sms_token'];
//        var_dump($_M['form']);die;
 
 
        $Q1 = "SELECT ID FROM {$_M['table']['config']} WHERE NAME = 'met_sms_user'";
        $r1 = DB::query($Q1);
        $Q2 = "SELECT ID FROM {$_M['table']['config']} WHERE NAME = 'met_sms_sing'";
        $r2 = DB::query($Q2);
        if (!$r1->lengths && !$r2->lengths){
            $query3 = "INSERT INTO `{$_M['table']['config']}` SET
                    `id`        =  '',
                    `name`        =  'met_sms_user',
                    `mobile_value`        =  '',
                    `columnid`        =  0,
                    `flashid`        =  0,
                    `value`        =  '{$_M['form']['met_sms_user']}',
                   `lang`        =  'metinfo'";
            DB::query($query3);
            $query4 = "INSERT INTO `{$_M['table']['config']}` SET
                    `id`        =  '',
                    `name`        =  'met_sms_sing',
                    `mobile_value`        =  '',
                    `columnid`        =  0,
                    `flashid`        =  0,
                   `value`        =  '{$_M['form']['met_sms_sing']}',
                   `lang`        =  'metinfo'";
            DB::query($query4);
            $query5 = "UPDATE {$_M['table']['config']} SET value = '{$token}' WHERE name = 'met_sms_token'";
            DB::query($query5);
            $this->success('''保存成功');
        }else{
            $query = "UPDATE {$_M['table']['config']} SET value = '{$token}' WHERE name = 'met_sms_token'";
            $query1 = "UPDATE {$_M['table']['config']} SET value = '{$_M['form']['met_sms_user']}' WHERE name = 'met_sms_user'";
            $query2 = "UPDATE {$_M['table']['config']} SET value = '{$_M['form']['met_sms_sing']}' WHERE name = 'met_sms_sing'";
            DB::query($query);
            DB::query($query1);
            DB::query($query2);
            $this->success('''保存成功');
        }
    }

3:打开项目:\app\app\met_sms\include\class\met_sms.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
public function auto_send($phone, $content)
    {
        global $_M;
        if ($phone == '') {
            return false;
        }
        $data = array(
            'sms_token' => $_M['config']['met_sms_token'],
            'sms_user' => $_M['config']['met_sms_user'],
            'sms_sing' => $_M['config']['met_sms_sing'],
            'phone' => $phone,
            'content' => $content,
            'url' => $_M['url']['web_site'],
            'user_key' => $_M['config']['met_secret_key'],
            'type' => 'auto_send',
        );
 
 
        $smsapi = "http://api.smsbao.com/";
        $user = $data['sms_user']; //短信平台帐号
        $pass = md5($data['sms_token']); //短信平台密码
        $content= '【'.$data['sms_sing'].'】'.$data['content'];//要发送的短信内容
        $phone = $data['phone'];//要发送短信的手机号码
        $sendurl = $smsapi."sms?u=".$user."&p=".$pass."&m=".$phone."&c=".urlencode($content);
        $res = file_get_contents($sendurl) ;
        $result = [];
        if ($res == 0){
          $result['status'] = 200;
          $result['msg'] = '发送成功';
        }else{
            $result['status'] = 100;
            $result['msg'] = '发送失败';
        }
        return $result;
    }

好了经过以上的添加,短信宝MetInfoV7.2.0系统增加手机验证就已经安装成功,可以正常使用了

报备一下短信宝的VIP模板,这样就可以走短信宝的优质通道了,即便遇到敏感文字我们都不会人工审核,短信内容3~5秒就可送达。

另外:我们已经开发好完整的MetInfoV7.2.0系统短信宝插件,点击此链接 下载及查看安装流程。

 
开源插件
文章标签