MeEdu_V2.5.2新增短信宝短信接口
发表日期:2020-04-09 文章编辑:短信宝小编 浏览次数:
一款开源免费的在线教育点播收费系统。今天小编就以新增短信接口为例,给大家讲解一下如何进行二次开发,使用的短信接口是我们短信宝短信群发平台的短信接口,我们短信宝短信群发平台的接口非常稳定,发送速度快,注册就送测试短信,推荐大家使用。
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,而是填写模板内容"></warn> </FormItem> <FormItem> <template v-slot:label>注册模板</template> <input type="text" v-model="setting.sms.gateways.smsbao.template.register" /> <warn text="注意:短信宝不是填写模板ID,而是填写模板内容"></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;//要发送的短信内容 $phone =$to;//要发送短信的手机号码 $sendurl = $smsapi."sms?u=".$user."&p=".$pass."&m=".$phone."&c=".$content; $result =file_get_contents($sendurl); return $result; } } |
经过上面的替换,短信宝的短信平台已经替换成功了,可以正常使用了。进行测试发送:

报备一下短信宝的VIP模板,这样就可以走短信宝的优质通道了,即便遇到敏感文字我们都不会人工审核,短信内容3~5秒就可送达。
另外:我们已经开发好完整的MeEdu_V2.5.2系统短信宝插件,点击此链接 下载及查看安装流程。
- 上一篇:CRMEBV3.21新增短信宝短信接口 下一篇:微课堂V2新增短信宝短信接口

