91成人在线播放_欧美一区二区视频在线观看_91精品国产高清久久久久久_国产精品久久亚洲不卡4k岛国


待發(fā)短信

在線客服
產(chǎn)品支持 短信寶客服
合作渠道 渠道合作
服務咨詢

4001-021-502

工作時間

9:00-21:00

likeshop新增短信寶短信接口

likeshop是一款開源的企業(yè)級B2C電商系統(tǒng),前端uni-app架構(gòu),極致節(jié)省開發(fā)成本,一次研發(fā),多端發(fā)布。后端ThinkPHP架構(gòu),國內(nèi)最流行的PHP研發(fā)框架,易用易學,好二開。小編對他還是比較了解的,今天小編就以新增短信接口為例,給大家講解一下如何進行二次開發(fā),使用的短信接口是我們短信寶短信群發(fā)平臺的短信接口,我們短信寶短信群發(fā)平臺的接口非常穩(wěn)定,發(fā)送速度快,注冊就送測試短信,推薦大家使用。

前提:需先執(zhí)行以下sql

?
1
INSERT INTO `ls_sms_config` ( `name`, `describe`, `sign`, `app_key`, `secret_key`, `status`, `del`) VALUES ('短信寶''短信寶短信服務''''''''0''0');

1:打開項目:application\common\behavior\SmsSend.php 修改run方法

?
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
 public function run($params)
    {
        try{
            $params['scene'] = $params['key'];
            $this->sms_key = $params['key'];
            $this->sms_params = $params['params'];
            $this->mobile = $params['mobile'];
            $result = $this->getSmsConfig($params['key']);
 
            if (true !== $result) {
                return $result;
            }
            $this->sms_log = new SmsLog();
            //短信內(nèi)容
            $this->setSmsContent();
            //短信驗證碼
            $this->setSmsCode();
            //增加短信記錄
            $this->createSmsLog();
 
            //增加通知記錄
            $this->notice_id = NoticeLogic::addNoticeLog($params, $this->sms, NoticeSetting::SMS_NOTICE, $this->content);
 
            $alisms = new Alisms($this->config);
            $res = $alisms->setMobile($this->mobile)
                ->setTemplateCode($this->sms['template_code'])
                ->setTemplateParam($this->sms_params)
                ->sendSms();
 
            if (isset($res['Code']) && $res['Code'] == 'OK') {
                $send_status = SmsLog::send_success;
                $this->updateSmsLog($send_status, $res);
                return true;
            else {
                $send_status = SmsLog::send_fail;
                $this->updateSmsLog($send_status, $res);
                $message = $res['Message'] ?? $res;
                throw new Exception('短信配置錯誤:' . $message);
            }
 
        catch (\Exception $e) {
            NoticeLogic::updateNotice($this->notice_id,  $e->getMessage());
        }
    }

2:打開項目:application\common\serve 新增 SmsBao.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
 public function run($params)
    {
        try{
            $params['scene'] = $params['key'];
            $this->sms_key = $params['key'];
            $this->sms_params = $params['params'];
            $this->mobile = $params['mobile'];
            $result = $this->getSmsConfig($params['key']);
 
            if (true !== $result) {
                return $result;
            }
            $this->sms_log = new SmsLog();
            //短信內(nèi)容
            $this->setSmsContent();
            //短信驗證碼
            $this->setSmsCode();
            //增加短信記錄
            $this->createSmsLog();
 
            //增加通知記錄
            $this->notice_id = NoticeLogic::addNoticeLog($params, $this->sms, NoticeSetting::SMS_NOTICE, $this->content);
 
            $alisms = new Alisms($this->config);
            $res = $alisms->setMobile($this->mobile)
                ->setTemplateCode($this->sms['template_code'])
                ->setTemplateParam($this->sms_params)
                ->sendSms();
 
            if (isset($res['Code']) && $res['Code'] == 'OK') {
                $send_status = SmsLog::send_success;
                $this->updateSmsLog($send_status, $res);
                return true;
            else {
                $send_status = SmsLog::send_fail;
                $this->updateSmsLog($send_status, $res);
                $message = $res['Message'] ?? $res;
                throw new Exception('短信配置錯誤:' . $message);
            }
 
        catch (\Exception $e) {
            NoticeLogic::updateNotice($this->notice_id,  $e->getMessage());
        }
    }

經(jīng)過上面的替換,短信寶的短信平臺已經(jīng)替換成功了,可以正常使用了。

報備一下短信寶的VIP模板,這樣就可以走短信寶的優(yōu)質(zhì)通道了,即便遇到敏感文字我們都不會人工審核,短信內(nèi)容3~5秒就可送達。

另外:我們已經(jīng)開發(fā)好完整的likeshop系統(tǒng)短信寶插件,點擊此鏈接 下載及查看安裝流程。

開源插件

最新更新

電商類

CMS類

微信類

文章標簽