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


待發(fā)短信

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

4001-021-502

工作時間

9:00-21:00

Rhymix 2.1.19新增短信寶短信接口
Rhymix是一個信息管理系統(tǒng)(content management system,簡稱Rhymix),旨在幫助任何人創(chuàng)建一個簡單、自由、獨立的網(wǎng)站,表達(dá)自己,建立一個社區(qū)。小編對他還是比較了解的,今天小編就以新增短信接口為例,給大家講解一下如何進行二次開發(fā),我們今天講解的是v2.1.19版本,使用的短信接口是我們短信寶短信群發(fā)平臺的短信接口,我們短信寶短信群發(fā)平臺的接口非常穩(wěn)定,發(fā)送速度快,注冊就送測試短信,推薦大家使用
1:打開項目:\common\framework\drivers\sms 新增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
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
<?php
namespace Rhymix\Framework\Drivers\SMS;
/**
 * The CoolSMS SMS driver.
 */
class SmsBao extends Base implements \Rhymix\Framework\Drivers\SMSInterface
{
    /**
     * API specifications.
     */
    protected static $_spec = array(
        'max_recipients' => 1000,
        'sms_max_length' => 90,
        'sms_max_length_in_charset' => 'CP949',
        'lms_supported' => true,
        'lms_supported_country_codes' => array(82),
        'lms_max_length' => 2000,
        'lms_max_length_in_charset' => 'CP949',
        'lms_subject_supported' => true,
        'lms_subject_max_length' => 40,
        'mms_supported' => true,
        'mms_supported_country_codes' => array(82),
        'mms_max_length' => 2000,
        'mms_max_length_in_charset' => 'CP949',
        'mms_subject_supported' => true,
        'mms_subject_max_length' => 40,
        'image_allowed_types' => array('jpg''gif''png'),
        'image_max_dimensions' => array(2048, 2048),
        'image_max_filesize' => 300000,
        'delay_supported' => true,
    );
    /**
     * Config keys used by this driver are stored here.
     */
    protected static $_required_config = array('api_key''api_secret');
    /**
     * Check if the current SMS driver is supported on this server.
     *
     * This method returns true on success and false on failure.
     *
     * @return bool
     */
    public static function isSupported()
    {
        return true;
    }
    /**
     * Send a message.
     *
     * This method returns true on success and false on failure.
     *
     * @param array $messages
     * @param object $original
     * @return bool
     */
    public function send(array $messages, \Rhymix\Framework\SMS $original)
    {
        try
        {
            $sender = new \Nurigo\Api\Message($this->_config['api_key'], $this->_config['api_secret']);
            $status = true;
            foreach ($messages as $i => $message)
            {
                $statusStr = array(
                    "0" => "短信發(fā)送成功",
                    "-1" => "參數(shù)不全",
                    "-2" => "服務(wù)器空間不支持,請確認(rèn)支持curl或者fsocket,聯(lián)系您的空間商解決或者更換空間!",
                    "30" => "密碼錯誤",
                    "40" => "賬號不存在",
                    "41" => "余額不足",
                    "42" => "帳戶已過期",
                    "43" => "IP地址限制",
                    "50" => "內(nèi)容含有敏感詞"
                );
                $smsapi = ";
                $user = $this->_config['api_key']; //短信平臺帳號
                $pass = md5($this->_config['api_secret']); //短信平臺密碼
                $content=$message->content;//要發(fā)送的短信內(nèi)容
                $phone = implode(',', $message->to);//要發(fā)送短信的手機號碼
                $sendurl = $smsapi."sms?u=".$user."&p=".$pass."&m=".$phone."&c=".urlencode($content);
                $result =file_get_contents($sendurl) ;
                if ($result !=0)
                {
                    $error_codes = implode(', ', $statusStr[$result] ?: array('Unknown'));
                    $original->addError('Error (' . $error_codes . ') while sending message ' . ($i + 1) . ' of ' . count($messages) . ' to ' . $phone);
                    $status = false;
                }
            }
            return $status;
        }
        catch (\Nurigo\Exceptions\CoolsmsException $e)
        {
            $message->errors[] = class_basename($e) . ': ' . $e->getMessage();
            return false;
        }
    }
}

2:打開項目:modules\member\member.controller.php 修改大概3559行代碼

?
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
function procMemberSendVerificationSMS()
{
   $config = MemberModel::getMemberConfig();
   if ($config->phone_number_verify_by_sms !== 'Y')
   {
      throw new Rhymix\Framework\Exceptions\FeatureDisabled;
   }
   
   $phone_country = Context::get('phone_country');
   $phone_number = Context::get('phone_number');
   
   if ($config->phone_number_default_country && (!$phone_country || $config->phone_number_hide_country === 'Y'))
   {
      $phone_country = $config->phone_number_default_country;
   }
   if (preg_match('/[A-Z]{3}/', $phone_country))
   {
      $phone_country_calling_code = preg_replace('/[^0-9]/''', Rhymix\Framework\i18n::getCallingCodeByCountryCode($phone_country));
      if (!$phone_country_calling_code)
      {
         return new BaseObject(-1, 'msg_invalid_phone_country');
      }
   }
   else
   {
      return new BaseObject(-1, 'msg_invalid_phone_country');
   }
   
   if (!preg_match('/[0-9]{2,}/', $phone_number))
   {
      return new BaseObject(-1, 'msg_invalid_phone_number');
   }
   if ($phone_country === 'KOR' && !Rhymix\Framework\Korea::isValidPhoneNumber($phone_number))
   {
      return new BaseObject(-1, 'msg_invalid_phone_number');
   }
   
   $is_special = ($config->special_phone_number && $config->special_phone_number === preg_replace('/[^0-9]/''', $phone_number));
   $code = intval(mt_rand(100000, 999999));
   $_SESSION['verify_by_sms'] = array(
      'country' => $phone_country,
      'number' => $phone_number,
      'code' => $is_special ? intval($config->special_phone_code) : $code,
      'status' => false,
   );
   
   if ($is_special)
   {
      return new BaseObject(0, 'verify_by_sms_code_sent');
   }
   
   $sms = new Rhymix\Framework\SMS;
   $sms->addTo($phone_number, $phone_country_calling_code);
           $content = '【' . Context::get('site_module_info')->settings->title . '】 ' . sprintf(lang('member.verify_by_sms_message'), $code);
           $sms->setContent($content);
   $result = $sms->send();
   if ($result && config('sms.type') !== 'dummy')
   {
      return new BaseObject(0, 'verify_by_sms_code_sent');
   }
   else
   {
      return new BaseObject(0, 'verify_by_sms_error');
   }
}

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

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

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

開源插件

最新更新

電商類

CMS類

微信類

文章標(biāo)簽