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


待發短信

在線客服
產品支持 短信寶客服
合作渠道 渠道合作
服務咨詢

4001-021-502

工作時間

9:00-21:00

智簡魔方財務新增短信寶短信接口

智簡魔方財務管理系統是一套基于PHP+MYSQL構建開源的IDC財務管理系統。具有豐富的插件市場,今天小編就以新增短信接口為例,給大家講解一下如何進行二次開發,使用的短信接口是我們短信寶短信群發平臺的短信接口,我們短信寶短信群發平臺的接口非常穩定,發送速度快,注冊就送測試短信,推薦大家使用
├─smsbao插件目錄
│ ├─config
│ │ ├─description.html
│ │ ├─smsTemplate.php 相關短信模板
│ ├─config.php 短信寶設置
│ ├─SmsbaoPlugin.php 短信寶插件信息描述以及核心發送類
下面具體給大家說一下每個文件的作用及代碼,
1:打開項目:config/smsTemplate.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
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<?php
return [
    [
        'type' => '賬單支付',
        'var' => '${username},您已成功支付賬單號#${invoiceid},賬單金額${total}.',
        'name'=>'invoice_pay'
    ],
    [
        'type' => '賬單支付逾期',
        'var' => '${username},您的賬單【${invoiceid}】已逾期,金額${total},請及時支付',
        'name'=>'invoice_overdue_pay'
    ],
    [
        'type' => '提交工單',
        'var' => '${username},您的工單:【${subject}】正在處理中,請耐心等待',
        'name'=>'submit_ticket'
    ],
    [
        'type'=> '工單回復',
        'var' => '${username},您的工單【${subject}】有新回復',
        'name'=>'ticket_reply'
    ],
    [
        'type' => '產品暫停',
        'var' => '${username},您的產品${product_name}由于${description}已被暫停,如需恢復使用,請盡快處理',
        'name'=>'host_suspend'
    ],
    [
        'type' => '未支付賬單',
        'var' => '${username},您的賬單【#${invoiceid}】,金額${total},尚未支付',
        'name'=>'unpay_invoice'
    ],
    [
        'type' => '發送驗證碼',
        'var' => '驗證碼${code},5分鐘內有效,請勿泄漏于他人',
        'name'=>'send_code'
    ],
    [
        'type'=>'登錄短信提醒',
        'var'=> '${username},您于${time}在IP${address}登錄.如不是您的登錄,請立即更改密碼.',
        'name'=>'login_sms_remind'
    ],
    [
        'type' => '訂單退款',
        'var' => '訂單${order_id},金額${order_total_fee}已退款',
        'name'=>'order_refund'
    ],
    [
        'type' => '訂單支付提醒(客戶)',
        'var' => '您的訂單【${order_id}】已付款,金額:${order_total_fee}',
        'name'=>'invoice_payment_confirmation'
    ],
    [
        'type'=> '賬單未付款提醒',
        'var' => '${username},您的產品${product_name}(主機名${hostname})將于${product_end_time}到期.請及時續費',
        'name'=>'second_renew_product_reminder'
    ],
    [
        'type' => '自動生成續費賬單提醒',
        'var' => '您購買的產品${product_name}(主機名${hostname})將于${product_end_time}到期,到期后將無法使用',
        'name'=>'renew_product_reminder'
    ],
    [
        'type' => '第3次逾期提醒',
        'var' => '您在${product_first_time}訂購的${product_name}產品(主機名:${hostname})請及時支付',
        'name'=>'third_invoice_payment_reminder'
    ],
    [
        'type' => '第2次逾期提醒',
        'var' => '您在${product_first_time}訂購的${product_name}產品(主機名:${hostname})請及時支付',
        'name'=>'second_invoice_payment_reminder'
    ],
    [
        'type'=>'第1次逾期提醒',
        'var'=> '您在${product_first_time}訂購的${product_name}產品(主機名:${hostname})請及時支付',
        'name'=>'first_invoice_payment_reminder'
    ],
    [
        'type'=>'下單提醒(客戶)',
        'var'=> '您已于${order_create_time}成功下單${product_name},總價${product_price},請及時付款',
        'name'=>'new_order_notice'
    ],
    [
        'type'=>'產品開通提醒(用戶)',
        'var'=> '您購買的【${product_name}】已開通!',
        'name'=>'default_product_welcome'
    ],
    [
        'type'=>'未續期產品刪除提醒(用戶)',
        'var'=> '產品${product_name}(${hostname})${product_mainip}未續費,已自動刪除',
        'name'=>'service_termination_notification'
    ],
    [
        'type'=>'續費成功提醒(用戶)',
        'var'=> '您購買的產品(${product_name})現已續費成功,到期時間${product_end_time}',
        'name'=>'service_unsuspension_notification'
    ],
    [
        'type'=>'未實名暫停產品',
        'var'=> '您的產品:${product_name},${product_mainip},由于未實名,已被暫停',
        'name'=>'uncertify_reminder'
    ],
    [
        'type'=>'工單已開通提醒(客戶)',
        'var'=> '工單:【${ticketnumber_tickettitle}】火速處理中',
        'name'=>'support_ticket_opened'
    ],
    [
        'type'=>'成功綁定提醒(客戶)',
        'var'=> '您的賬號${username}與此${epw_type}:(${epw_account})已成功進行綁定.',
        'name'=>'email_bond_notice'
    ],
    [
        'type'=>'注冊成功',
        'var'=> '${username},感謝注冊${system_companyname}',
        'name'=>'registration_success'
    ],
    [
        'type'=>'信用額賬單提醒',
        'var'=> '您有一筆信用額賬單產生:賬單號#${invoiceid},金額${total},請及時付款',
        'name'=>'credit_limit_invoice_notice'
    ],
    [
        'type'=>'信用額賬單逾期提醒',
        'var'=> '您有一筆信用額賬單#${invoiceid},金額${total}逾期未支付,相關產品已被暫停',
        'name'=>'credit_limit_invoice_payment_reminder'
    ],
    [
        'type'=>'信用額賬單未支付暫停產品',
        'var'=> '您購買的產品:${product_name},(${hostname})由于未支付信用賬單,現已被暫停',
        'name'=>'credit_limit_invoice_payment_reminder_host_suspend'
    ],
    [
        'type'=>'解除暫停提醒(用戶)',
        'var'=> '您擁有的產品${product_name}現已解除暫停恢復使用,感謝您的支持!',
        'name'=>'resume_use'
    ],
    [
        'type'=>'實名認證通過提醒(用戶)',
        'var'=> '${username},您提交的實名認證審核已通過!',
        'name'=>'realname_pass_remind'
    ],
    [
        'type'=>'賬號綁定提示(用戶)',
        'var'=> '${username},您已綁定[${system_companyname}],如非您本人操作,請立即更改登錄密碼',
        'name'=>'binding_remind'
    ],
];

2:打開項目:config.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
<?php
/*
 
 */
return [
   'user'=> [
      'title' => '短信寶賬號',
      'type'  => 'text'
      'value' => '',
      'tip'   => '',
   ],
   'pass'=> [
      'title' => '短信寶密碼',
      'type'  => 'text'
      'value' => '',
      'tip'   => ''
   ],
   'sign'=> [
      'title' => '簽名',
      'type'  => 'text',
      'value' => '',
      'tip'   => ''
   ],
];

3:打開項目:SmsbaoPlugin.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
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<?php
namespace sms\simple;
 
use app\admin\lib\Plugin;
 
 
class SmsbaoPlugin extends Plugin
{
    # 基礎信息
    public $info = array(
        'name'        => 'Smsbao',
        'title'       => 'Smsbao短信服務',
        'description' => 'Smsbao短信服務',
        'status'      => 1,
        'author'      => '小樂',
        'version'     => '1.0',
        'help_url'     => 'http://www.gjrencai.com/',//申請接口地址
    );
 
    # 插件安裝
    public function install()
    {
        //導入模板
        $smsTemplate= [];
        if (file_exists(__DIR__.'/config/smsTemplate.php')){
            $smsTemplate = require __DIR__.'/config/smsTemplate.php';
        }
        return $smsTemplate;
    }
 
    # 插件卸載
    public function uninstall()
    {
        return true;//卸載成功返回true,失敗false
    }
    # 后臺頁面創建模板時可用參數
    public function description()
    {
        return file_get_contents(__DIR__.'/config/description.html');    
    
    #獲取國內模板
    public function getCnTemplate($params)
    {              
        $data['status']='success';
        $data['template']['template_status']=2;
        return $data;
    }
    #創建國內模板
    public function createCnTemplate($params)
    {
        $data['status']='success';
        $data['template']['template_status']=2;
        return $data;
    }
    #修改國內模板
    public function putCnTemplate($params)
    {
        $data['status']='success';
        $data['template']['template_status']=2;
        return $data;
    }
    #刪除國內模板
    public function deleteCnTemplate($params)
    {
        $data['status']='success';
        return $data;
    }
    #發送國內短信
    public function sendCnSms($params)
    {       
        $content=$this->templateParam($params['content'],$params['templateParam']);
        $param['content']=$this->templateSign($params['config']['sign']).$content;
        $param['mobile']=trim($params['mobile']);
        $resultTemplate= $this->APIHttpRequestCURL('cn',$param,$params['config']);
        if($resultTemplate['status']=="success"){
            $data['status']="success";
            $data['content']=$content;
        }else{
            $data['status']="error";
            $data['content']=$content;
            $data['msg']=$resultTemplate['msg'];
        }
        return $data;
    }  
    #獲取國際模板
    public function getGlobalTemplate($params)
    {      
        $data['status']='success';
        $data['template']['template_status']=2;
        return $data;
    }
    #創建國際模板
    public function createGlobalTemplate($params)
    {
        $data['status']='success';
        $data['template']['template_status']=2;
        return $data;
    }
    #修改國際模板
    public function putGlobalTemplate($params)
    {
        $data['status']='success';
        $data['template']['template_status']=2;
        return $data;
    }
    #刪除國際模板
    public function deleteGlobalTemplate($params)
    {
        $data['status']='success';
        return $data;
    }
    #發送國際短信
    public function sendGlobalSms($params)
    {
        $content=$this->templateParam($params['content'],$params['templateParam']);
        $param['content']=$this->templateSign($params['config']['sign']).$content;
        $param['mobile']=trim($params['mobile']);
        $resultTemplate= $this->APIHttpRequestCURL('global',$param,$params['config']);
        if($resultTemplate['status']=="success"){
            $data['status']="success";
            $data['content']=$content;
        }else{
            $data['status']="error";
            $data['content']=$content;
            $data['msg']=$resultTemplate['msg'];
        }
        return $data;
    }  
    # 以下函數名自定義
 
    private function APIHttpRequestCURL($sms_type = 'cn',$params,$config){
        $url = ($sms_type === 'cn') ? ' ';
        $statusStr = array(
            "0" => "短信發送成功",
            "-1" => "參數不全",
            "-2" => "服務器空間不支持,請確認支持curl或者fsocket,聯系您的空間商解決或者更換空間!",
            "30" => "密碼錯誤",
            "40" => "賬號不存在",
            "41" => "余額不足",
            "42" => "帳戶已過期",
            "43" => "IP地址限制",
            "50" => "內容含有敏感詞",
            "51" => "手機號碼不正確"
        );
        $user = $config['user']; //短信平臺帳號
        $pass = md5($config['pass']); //短信平臺密碼
        $content= $params['content'];//要發送的短信內容
        $phone = $params['mobile'];//要發送短信的手機號碼
        $sendurl = $url."?u=".$user."&p=".$pass."&m=".$phone."&c=".urlencode($content);
        $result =file_get_contents($sendurl) ;
        //短信發送成功返回True,失敗返回false
        if ($result  == '0') {
            return array('status' => "success"'msg' => $statusStr[$result]);
        else {
            return array('status' => "error"'msg' =>  $statusStr[$result] . '. Code: ' . $result);
        }
    }
 
    private function templateParam($content,$templateParam){
        foreach ($templateParam as $key => $para) {
            $content = str_replace('{' . $key . '}', $para, $content);//模板中的參數替換
        }       
        return $content;
    }
    private function templateSign($sign){
        $sign = str_replace("【","",$sign);
        $sign = str_replace("】","",$sign);
        $sign = "【".$sign."】";  
        return $sign;
    }
}

經過上面的替換,短信寶的短信平臺已經替換成功了,可以正常使用了。進行測試發送:

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

另外:我們已經開發好完整的智簡魔方財務系統短信寶插件,點擊此鏈接?下載及查看安裝流

開源插件

最新更新

電商類

CMS類

微信類

文章標簽