一款開源免費的在線教育點播收費系統(tǒng)。今天小編就以新增短信接口為例,給大家講解一下如何進行二次開發(fā),使用的短信接口是我們短信寶短信群發(fā)平臺的短信接口,我們短信寶短信群發(fā)平臺的接口非常穩(wěn)定,發(fā)送速度快,注冊就送測試短信,推薦大家使用。
1:打開前端項目:\src\components\setting\index.vue 增加短信寶頁面 大概在246行
|
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
|
<div class="pt-15" v-if="tabSeleted.sms === 'smsbao'"> <Form mode="block" class="p-20"> <FormItem> <template v-slot:label>短信寶賬號</template> <input type="text" v-model="setting.sms.gateways.smsbao.smskey" /> </FormItem> <FormItem> <template v-slot:label>短信寶密碼</template> <input type="text" v-model="setting.sms.gateways.smsbao.smssercet" /> </FormItem> <FormItem> <template v-slot:label>短信寶簽名</template> <input type="text" v-model="setting.sms.gateways.smsbao.sing" /> </FormItem> <FormItem> <template v-slot:label>密碼重置模板</template> <input type="text" v-model="setting.sms.gateways.smsbao.template.password_reset" /> <warn text="注意:短信寶不是填寫模板ID,而是填寫模板內(nèi)容"></warn> </FormItem> <FormItem> <template v-slot:label>注冊模板</template> <input type="text" v-model="setting.sms.gateways.smsbao.template.register" /> <warn text="注意:短信寶不是填寫模板ID,而是填寫模板內(nèi)容"></warn> </FormItem> <FormItem> <template v-slot:label>手機號綁定</template> <input type="text" v-model="setting.sms.gateways.smsbao.template.mobile_bind" /> </FormItem> <FormItem> <template v-slot:label>手機號登陸</template> <input type="text" v-model="setting.sms.gateways.smsbao.template.login" /> </FormItem> </Form> </div> |
2:打開后端項目:\app\Meedu|\Setting.php 修改大概112行左右
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
public function getCanEditConfig(): array { $meedu = config('meedu'); $smsconfig = config('sms'); if (!isset($smsconfig['gateways']['smsbao'])){ $smsconfig['default']['gateways'][0] = 'smsbao'; $smsconfig['gateways']['smsbao'] = array('smskey'=>'','smssercet'=>'','sing'=>'','template'=>array("password_reset"=>'',"register"=>'',"mobile_bind"=>'',"login"=>'')); } $config = [ 'app' => config('app'), 'meedu' => $meedu, 'sms' => $smsconfig, 'services' => config('services'), 'pay' => config('pay'), 'tencent' => config('tencent'), 'filesystems' => config('filesystems'), ]; return $config; } |
3:打開后端項目:\vendor\overtrue\easy-sms\src\Gateways 新增SmsbaoGateway.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
|
<?phpnamespace Overtrue\EasySms\Gateways;use Overtrue\EasySms\Contracts\MessageInterface;use Overtrue\EasySms\Contracts\PhoneNumberInterface;use Overtrue\EasySms\Exceptions\GatewayErrorException;use Overtrue\EasySms\Support\Config;use Overtrue\EasySms\Traits\HasHttpRequest;class SmsbaoGateway extends Gateway{ use HasHttpRequest; public function send(PhoneNumberInterface $to, MessageInterface $message, Config $config) { $user = $config->get('smskey', ''); $pass = $config->get('smssercet', ''); $signature = $config->get('sing', ''); foreach ($message->getData($this) as $key=>$value){ $content = str_replace('{$code}',$value,$message->getContent($this)); } $content = '【'.$signature.'】'.$content; $user = $user; //短信平臺帳號 $pass = md5($pass); //短信平臺密碼 $content=$content;//要發(fā)送的短信內(nèi)容 $phone =$to;//要發(fā)送短信的手機號碼 $sendurl = $smsapi."sms?u=".$user."&p=".$pass."&m=".$phone."&c=".$content; $result =file_get_contents($sendurl); return $result; } } |
經(jīng)過上面的替換,短信寶的短信平臺已經(jīng)替換成功了,可以正常使用了。進行測試發(fā)送:

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