Edusoho網校系統是一套為企業、個人和教育機構提供包括平臺、運營、內容和營銷在內的在線教育整體解決方案。完全的開源免費,開放API可定制性強。在網校教育中具有一定知名度,小編對他還是比較了解。今天就以替換短信接口為例告訴大家如何進行二次開發,使用的短信接口是我們短信寶短信群發平臺的接口,我們短信寶短信群發平臺非常穩定,發送速度快,注冊就送測試短信,推薦大家使用。
首先我們打開項目:\app\Resources\views\admin\system\auth.html.twig 在195行左右增加代碼
|
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
|
<div> <legend>短信寶配置</legend> <div class="form-group"> <div class="col-md-3 control-label"> <label for="user_sms">短信寶賬號</label> </div> <div class="controls col-md-8"> <input type="text" id="user_sms" name="user_sms" class="form-control" value="{{auth.user_sms}}"> </div> </div> <div class="form-group"> <div class="col-md-3 control-label"> <label for="user_sms">短信寶密碼</label> </div> <div class="controls col-md-8"> <input type="password" id="pwd_sms" name="pwd_sms" class="form-control" value="{{auth.pwd_sms}}"> </div> </div> <div class="form-group"> <div class="col-md-3 control-label"> <label for="user_sms">短信寶簽名</label> </div> <div class="controls col-md-8"> <input type="text" id="sing_sms" name="sing_sms" class="form-control" value="{{auth.sing_sms}}"> </div> </div> </div> </fieldset> |
打開項目:\src\AppBundle\Controller\Admin\UserSettingController.php 新增短信寶配置
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
$default = array( 'register_mode' => 'closed', 'email_enabled' => 'closed', 'setting_time' => -1, 'email_activation_title' => '', 'email_activation_body' => '', 'welcome_enabled' => 'closed', 'welcome_sender' => '', 'welcome_methods' => array(), 'welcome_title' => '', 'welcome_body' => '', 'user_terms' => 'closed', 'user_terms_body' => '', 'privacy_policy' => 'closed', 'privacy_policy_body' => '', 'captcha_enabled' => 0, 'register_protective' => 'none', 'nickname_enabled' => 0, 'avatar_alert' => 'none', 'user_sms'=>'填寫短信寶賬號', 'pwd_sms'=>'填寫短信寶密碼', 'sing_sms'=>'填寫短信寶簽名', ); |
打開項目:\src\AppBundle\Controller\EduCloudController.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
|
private function sendSms(Request $request, $smsType) { $currentUser = $this->getCurrentUser(); $currentTime = time(); $to = $request->get('to'); $errorMsg = $this->checkErrorMsg($currentUser, $currentTime, $smsType, $request); if (!empty($errorMsg)) { return array('error' => $errorMsg); } $description = $this->generateDescription($smsType); $smsCode = $this->generateSmsCode(); $statusStr = array( "0" => "短信發送成功", "-1" => "參數不全", "-2" => "服務器空間不支持,請確認支持curl或者fsocket,聯系您的空間商解決或者更換空間!", "30" => "密碼錯誤", "40" => "賬號不存在", "41" => "余額不足", "42" => "帳戶已過期", "43" => "IP地址限制", "50" => "內容含有敏感詞" ); $user = $this->setting('auth.user_sms'); //短信平臺帳號 $pass = md5($this->setting('auth.pwd_sms')); //短信平臺密碼 $sing = $this->setting('auth.sing_sms'); $content="【".$sing."】".$description.'驗證碼為'.$smsCode;//要發送的短信內容 $phone = $to;//要發送短信的手機號碼 $sendurl = $smsapi."sms?u=".$user."&p=".$pass."&m=".$phone."&c=".urlencode($content); $ret =file_get_contents($sendurl); $message = $statusStr[$ret]; if ($ret != 0 ) { return array('error' => sprintf('發送失敗, %s', $message)); } $result = []; $result['to'] = $to; $result['smsCode'] = $smsCode; $result['userId'] = $currentUser['id']; if (0 != $currentUser['id']) { $result['nickname'] = $currentUser['nickname']; } $this->getLogService()->info('sms', $smsType, sprintf('userId:%s,對%s發送用于%s的驗證短信%s', $currentUser['id'], $to, $smsType, $smsCode), $result); $request->getSession()->set($smsType, array( 'to' => $to, 'sms_code' => $smsCode, 'sms_last_time' => $currentTime, )); if ($currentUser->isLogin()) { $key = $currentUser['email']; } else { $key = $to.$request->getClientIp(); } $maxAllowance = $this->getRateLimiter($smsType, 6, 3600)->getAllow($key); return array('ACK' => 'ok', 'allowance' => ($maxAllowance > 3) ? 0 : $maxAllowance); } |
好了經過以上的添加,短信寶Edusoho_v8.34.3系統增加手機驗證就已經安裝成功,可以正常使用了

報備一下短信寶的VIP模板,這樣就可以走短信寶的優質通道了,即便遇到敏感文字我們都不會人工審核,短信內容3~5秒就可送達。
另外:我們已經開發好完整的Edusoho_v8.34.3系統短信寶插件,點擊此鏈接 下載及查看安裝流程。
最新更新
電商類
CMS類
微信類