待发短信

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

4001-021-502

工作时间

9:00-21:00

YAuthV1.0.6新增短信宝短信接口

YAuth是一款全新架构的企业级产品授权官网,内置各种强大的功能,使用方便快捷,支付模块集成易支付功能,前台支持自助购买和操作管理授权。小编对他还是比较了解的,今天小编就以新增短信接口为例,给大家讲解一下如何进行二次开发,使用的短信接口是我们短信宝短信群发平台的短信接口,我们短信宝短信群发平台的接口非常稳定,发送速度快,注册就送测试短信,推荐大家使用。
1:打开项目:\admin\oreo_mail.php 修改大概40行 修改为短信宝

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
<div class="row">
    <div class="col-lg98-6">
        <div class="card m-b-30">
            <div class="card-body">
                <h4 class="mt-0 header-title">邮件短信置说明</h4>
                <p class="text-muted m-b-30 font-14">在这里您可以设置平台的邮箱参数,请认真填写每一项,否则不能发送有关邮件验证!</p>
                <div class="form-group">
                    <label>邮箱开关</label>
                    <select class="form-control" name="mail_cloud" id="mail_cloud" onchange="sh_rg('sh',this.value)">
                        <option value="2" <?= $conf['mail_cloud'] == 2 ? "selected" "" ?> >短信宝短信</option>
                        <option value="1" <?= $conf['mail_cloud'] == 1 ? "selected" "" ?> >SMTP发信</option>
                        <option value="0" <?= $conf['mail_cloud'] == 0 ? "selected" "" ?> >关闭邮箱验证</option>
                    </select>
                </div>
                <div id="sh_reg" style="<?php echo $conf['mail_cloud'] == 1 ? "" : "display: none;"; ?>">
                    <div class="form-group">
                        <label>SMTP地址</label>
                        <div>
                            <input type="text" class="form-control" name="mail_smtp" placeholder="如:smtp.qq.com"
                                   value="<?php echo $conf['mail_smtp']; ?>" class="form-control"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label>SMTP端口</label>
                        <div>
                            <input type="text" class="form-control" placeholder="一般465或25" name="mail_port"
                                   value="<?php echo $conf['mail_port']; ?>"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label>邮箱账号</label>
                        <div>
                            <input type="text" class="form-control" placeholder="请输入邮箱账号" name="mail_name"
                                   value="<?php echo $conf['mail_name']; ?>"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label>邮箱密码</label>
                        <div>
                            <input type="text" class="form-control" placeholder="请输入正确的密码/授权码" name="mail_pwd"
                                   value="<?php echo $conf['mail_pwd']; ?>"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label>极限验证ID</label>
                        <div>
                            <input class="form-control" type="text range" name="CAPTCHA_ID"
                                   value="<?php echo $conf['CAPTCHA_ID']; ?>"/>
                            <small>* Geetest极限验证码官网https://www.geetest.com/</small>
                        </div>
                    </div>
                    <div class="form-group">
                        <label>极限验证KEY</label>
                        <div>
                            <input type="text" class="form-control" name="PRIVATE_KEY"
                                   value="<?php echo $conf['PRIVATE_KEY']; ?>"/>
                        </div>
                    </div>
                </div>
                <div id="sh_ten" style="<?php echo $conf['mail_cloud'] == 2 ? "" : "display: none;"; ?>">
                    <div class="form-group">
                        <label>短信宝账号</label>
                        <div>
                            <input type="text" class="form-control" name="oreo_tenmsg_appid"
                                   value="<?php echo $conf['oreo_tenmsg_appid']; ?>"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label>短信宝密码</label>
                        <div>
                            <input type="text" class="form-control" name="oreo_tenmsg_key"
                                   value="<?php echo $conf['oreo_tenmsg_key']; ?>"/>
                        </div>
                    </div>
                    <!--                                             <div class="form-group">-->
                    <!--                                                    <label>短信模板</label>-->
                    <!--                                                    <div>-->
                    <!--                                                        <input type="text" class="form-control" name="oreo_tenmsg_templateId" value="-->
                    <?php //echo $conf['oreo_tenmsg_templateId']; ?><!--"/>-->
                    <!--                                                    </div>-->
                    <!--                                                </div>-->
                    <div class="form-group">
                        <label>短信签名</label>
                        <div>
                            <input type="text" class="form-control" name="oreo_tenmsg_smsSign"
                                   value="<?php echo $conf['oreo_tenmsg_smsSign']; ?>"/>
                        </div>
                        <small>* 签名参数使用的是`签名内容`,而不是`签名ID`</small>
                    </div>
                </div>
 
                <div class="form-group m-b-0">
                    <div>
                        <button type="button" id="dispatch" value="保存修改"
                                class="btn btn-primary waves-effect waves-light">
                            提交
                        </button>
                        <button type="reset" class="btn btn-secondary waves-effect m-l-5">
                            重置
                        </button>
                    </div>
                </div>
            </div>
        </div>
    </div>

2:打开项目 \oreo\oreo_plugin\tenmsg\SmsSingleSender.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
public function __construct($appid, $appkey)
    {
        $this->url = "http://api.smsbao.com/sms";
        $this->appid =  $appid;
        $this->appkey = $appkey;
        $this->util = new SmsSenderUtil();
    
public function send($type, $nationCode, $phoneNumber, $msg, $extend = "", $ext = "")
    {
        $wholeUrl = $this->url;
        $data = [];
        $data['u'] = $this->appid; //短信平台帐号
        $data['p'] = md5($this->appkey); //短信平台密码
        $data['c']=$msg;//要发送的短信内容
        $data['m']  = $phoneNumber;//要发送短信的手机号码
        return $this->util->sendCurlPost($wholeUrl, $data);
    }
    public function sendCurlPost($url, $dataObj)
    {
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, $url);
        curl_setopt($curl, CURLOPT_HEADER, 0);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($curl, CURLOPT_POST, 1);
        curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 60);
        curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($dataObj));
        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
 
        $ret = curl_exec($curl);
        if (false == $ret) {
            // curl_exec failed
            $result = "{ \"result\":" . -2 . ",\"errmsg\":\"" . curl_error($curl) . "\"}";
        else {
            $rsp = curl_getinfo($curl, CURLINFO_HTTP_CODE);
            if ($ret == '0'){
                $result = "{ \"result\":" . 0 . ",\"errmsg\":\"" . $rsp
                    "\"}";
            }else{
                $rsp = '发送失败';
                $result = "{ \"result\":" . -1 . ",\"errmsg\":\"". $rsp
                    " "  ."\"}";
            }
        }
        curl_close($curl);
        return $result;
    }

经过上面的替换,短信宝的短信平台已经替换成功了,可以正常使用了。进行测试发送:

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

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

开源插件

最新更新

电商类

CMS类

微信类

文章标签