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->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類
微信類