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


待發(fā)短信

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

4001-021-502

工作時(shí)間

9:00-21:00

shopxoV5.0新增短信寶短信接口

ShopXO是國(guó)內(nèi)領(lǐng)先的商城系統(tǒng)提供商,為企業(yè)提供php商城系統(tǒng)、微信商城、小程序。小編發(fā)現(xiàn)ShopXO更新到5.0版本,就以替換短信接口為例告訴大家如何進(jìn)行二次開(kāi)發(fā),使用的短信接口是我們短信寶短信群發(fā)平臺(tái)的接口,我們短信寶短信群發(fā)平臺(tái)非常穩(wěn)定,發(fā)送速度快,注冊(cè)就送測(cè)試短信,推薦大家使用
1:打開(kāi)項(xiàng)目:\app\admin\view\default\sms\index.html文件,大概15行替換以下代碼

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
<form class="am-form form-validation am-form-popup-sticky" action="{{:MyUrl('admin/sms/save')}}" method="POST" request-type="ajax-view" request-value="{{:MyUrl('admin/sms/index', ['type'=>'index'])}}">
    <div class="nav-content">
        <!-- table tips start -->
        {{include file="sms/tips"" /}}
        <!-- table tips end -->
        <div class="am-form-group">
            <label>短信寶賬號(hào)<span class="am-form-group-label-tips">填寫(xiě)短信寶賬號(hào)</span></label>
            <input type="text" name="{{$data.common_sms_apikey.only_tag}}" placeholder="短信寶賬號(hào)" data-validation-message="{{$data.common_sms_apikey.error_tips}}" class="am-radius" {{if !empty($data)}}value="{{$data.common_sms_apikey.value}}"{{/if}} />
        </div>
        <div class="am-form-group">
            <label>短信寶密碼<span class="am-form-group-label-tips">填寫(xiě)短信寶密碼</span></label>
            <input type="text" name="{{$data.common_sms_apisecret.only_tag}}" placeholder="填寫(xiě)短信寶密碼" data-validation-message="{{$data.common_sms_apisecret.error_tips}}" class="am-radius" {{if !empty($data)}}value="{{$data.common_sms_apisecret.value}}"{{/if}} />
        </div>
        <div class="am-form-group">
            <label>短信寶簽名<span class="am-form-group-label-tips">填寫(xiě)短信寶簽名</span></label>
            <input type="text" name="{{$data.common_sms_sign.only_tag}}" placeholder="填寫(xiě)短信寶簽名" data-validation-message="{{$data.common_sms_sign.error_tips}}" class="am-radius" maxlength="16" {{if !empty($data)}}value="{{$data.common_sms_sign.value}}"{{/if}} />
        </div>
    </div>
    <div class="am-form-popup-submit">
        <button type="submit" class="am-btn am-btn-primary am-radius am-btn-xs btn-loading-example" data-am-loading="{spinner: 'circle-o-notch', loadingText:'{{:MyLang('save_title')}}'}">
            <i class="am-icon-save"></i>
            <span>{{:MyLang('save_title')}}</span>
        </button>
    </div>
</form>

2:打開(kāi)項(xiàng)目:\app\admin\view\default\sms\message.html 大概14行替換以下代碼

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
<form class="am-form form-validation am-form-popup-sticky" action="{{:MyUrl('admin/sms/save')}}" method="POST" request-type="ajax-view" request-value="{{:MyUrl('admin/sms/index', ['type'=>'message'])}}">
    <div class="nav-content">
        <!-- table tips start -->
        {{include file="sms/tips"" /}}
        <!-- table tips end -->
        <!-- 后臺(tái) -->
        <p class="am-margin-bottom-xl am-text-sm cr-333">{{:MyLang('sms.base_item_admin_title')}}</p>
        <div class="am-form-group">
            <label>短信登錄模板<span class="am-form-group-label-tips">{{$data.admin_sms_login_template.describe}}</span></label>
            <input type="text" name="{{$data.admin_sms_login_template.only_tag}}" placeholder="填寫(xiě)短信登錄模板" data-validation-message="{{$data.admin_sms_login_template.error_tips}}" class="am-radius" {{if !empty($data)}}value="{{$data.admin_sms_login_template.value}}"{{/if}} />
        </div>
        <!-- 前端 -->
        <p class="am-margin-bottom-xl am-text-sm cr-333">{{:MyLang('sms.base_item_index_title')}}</p>
        <div class="am-form-group">
            <label>通用-短信模板<span class="am-form-group-label-tips">{{$data.common_sms_currency_template.describe}}</span></label>
            <input type="text" name="{{$data.common_sms_currency_template.only_tag}}" placeholder="通用-短信模板" data-validation-message="{{$data.common_sms_currency_template.error_tips}}" class="am-radius" {{if !empty($data)}}value="{{$data.common_sms_currency_template.value}}"{{/if}} />
        </div>
        <div class="am-form-group">
            <label>用戶登錄-短信模板<span class="am-form-group-label-tips">{{$data.home_sms_login_template.describe}}</span></label>
            <input type="text" name="{{$data.home_sms_login_template.only_tag}}" placeholder="用戶登錄-短信模板" data-validation-message="{{$data.home_sms_login_template.error_tips}}" class="am-radius" {{if !empty($data)}}value="{{$data.home_sms_login_template.value}}"{{/if}} />
        </div>
        <div class="am-form-group">
            <label>用戶注冊(cè)-短信模板<span class="am-form-group-label-tips">{{$data.home_sms_user_reg_template.describe}}</span></label>
            <input type="text" name="{{$data.home_sms_user_reg_template.only_tag}}" placeholder="用戶注冊(cè)-短信模板 data-validation-message="{{$data.home_sms_user_reg_template.error_tips}}" class="am-radius" {{if !empty($data)}}value="{{$data.home_sms_user_reg_template.value}}"{{/if}} />
        </div>
        <div class="am-form-group">
            <label>密碼找回-短信模板<span class="am-form-group-label-tips">{{$data.home_sms_user_forget_pwd_template.describe}}</span></label>
            <input type="text" name="{{$data.home_sms_user_forget_pwd_template.only_tag}}" placeholder="密碼找回-短信模板" data-validation-message="{{$data.home_sms_user_forget_pwd_template.error_tips}}" class="am-radius" {{if !empty($data)}}value="{{$data.home_sms_user_forget_pwd_template.value}}"{{/if}} />
        </div>
        <div class="am-form-group">
            <label>手機(jī)號(hào)碼綁定-短信模板<span class="am-form-group-label-tips">{{$data.home_sms_user_mobile_binding_template.describe}}</span></label>
            <input type="text" name="{{$data.home_sms_user_mobile_binding_template.only_tag}}" placeholder="手機(jī)號(hào)碼綁定-短信模板" data-validation-message="{{$data.home_sms_user_mobile_binding_template.error_tips}}" class="am-radius" {{if !empty($data)}}value="{{$data.home_sms_user_mobile_binding_template.value}}"{{/if}} />
        </div>
    </div>
    <div class="am-form-popup-submit">
        <button type="submit" class="am-btn am-btn-primary am-radius am-btn-xs btn-loading-example" data-am-loading="{spinner: 'circle-o-notch', loadingText:'{{:MyLang('save_title')}}'}">
            <i class="am-icon-save"></i>
            <span>{{:MyLang('save_title')}}</span>
        </button>
    </div>
</form>

3:打開(kāi)項(xiàng)目:\app\admin\view\default\sms\tips.html 修改跳轉(zhuǎn)方式

1
2
3
4
5
6
7
8
<div class="am-operate-stretch-tips">
    <div class="title">
        <i class="iconfont icon-tips"></i>
        <strong title="{{:MyLang('operate_list_tips_msg')}}">{{:MyLang('operate_list_tips_button_text')}}</strong>
        <i class="iconfont icon-contract contract" title="{{:MyLang('operate_list_tips_retract_text')}}"></i> 
    </div>
</div>

4:打開(kāi)項(xiàng)目:\extend\base\Sms.php 修改短信發(fā)送函數(shù) 大概151行

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
public function SmsRequest($mobile, $template_value, $sign_name = '', $template_var = [])
{
    // 簽名
    $sign_name = empty($sign_name) ? $this->sign_ame : $sign_name;
    // 短信發(fā)送鉤子
    $hook_name = 'plugins_extend_sms_send_request_handle';
    $ret = array_filter(MyEventTrigger($hook_name, [
        'hook_name'       => $hook_name,
        'is_backend'      => true,
        'sign_name'       => $sign_name,
        'mobile'          => $mobile,
        'template_value'  => $template_value,
        'template_var'    => $template_var,
    ]));
    // 存在返回值,并且存在code和mag參數(shù),則認(rèn)為是鉤子處理短信的發(fā)送
    if(!empty($ret))
    {
        // 處理鉤子數(shù)據(jù)
        $ret = EventReturnHandle($ret);
        if($ret['code'] != 0)
        {
            $this->error = $ret['msg'];
            return false;
        }
        return true;
    }
    // 請(qǐng)求參數(shù)
    $request_url = ';
    $request_params = [
        'SignName'          => $sign_name,
        'Format'            => 'JSON',
        'Version'           => '2017-05-25',
        'AccessKeyId'       => $this->access_key_id,
        'Timestamp'         => gmdate('Y-m-d\TH:i:s\Z'),
        'Action'            => 'SendSms',
        'TemplateCode'      => $template_value,
        'PhoneNumbers'      => $mobile,
    ];
    // 攜帶參數(shù)
    if(!empty($template_var))
    {
        if(!is_array($template_var))
        {
            $template_var = ['code'=>$template_var];
        }
        $request_params['TemplateParam'] = json_encode($template_var, JSON_UNESCAPED_UNICODE);
    }
    $content = $template_value;
    foreach ($template_var as $k=>$v){
        $content = str_replace($k,$v,$content);
    }
    $SignName = empty($sign_name) ? $this->sign_ame : $sign_name;
    $url = $request_url.'?u='.$this->access_key_id.'&p='.md5($this->access_key_secret).'&m='.$mobile.'&c=【'.$SignName.'】'.$content;
    // 添加短信日志
    $log = SmsLogService::SmsLogAdd('smsbao', $mobile, $sign_name, $template_value, $template_var, $request_url, $request_params);
    if($log['code'] != 0)
    {
        $this->error = $log['msg'];
        return false;
    }
    $ch = curl_init ();
    curl_setopt ( $ch, CURLOPT_URL, $url );
    curl_setopt ( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
    curl_setopt ( $ch, CURLOPT_SSL_VERIFYHOST, FALSE );
    curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );
    curl_setopt ( $ch, CURLOPT_TIMEOUT, 10 );
    $result = curl_exec ( $ch );
    curl_close ( $ch );
    if($result == '0')
    {
        // 日志回調(diào)
        SmsLogService::SmsLogResponse($log['data']['id'], 1, $result, time()-$log['data']['add_time']);
        return true;
    }
    // 錯(cuò)誤原因
    $this->error = $this->GetErrorMessage($result);
    // 日志回調(diào)
    SmsLogService::SmsLogResponse($log['data']['id'], 2, $result, time()-$log['data']['add_time'], $this->error);
    return false;
}

經(jīng)過(guò)上面的替換,短信寶的短信平臺(tái)已經(jīng)替換成功了,可以正常使用了。進(jìn)行測(cè)試發(fā)送:

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

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

開(kāi)源插件

最新更新

電商類

CMS類

微信類

文章標(biāo)簽