|
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
|
<?phpnamespace 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" => "短信发送成功", "-1" => "参数不全", "-2" => "服务器空间不支持,请确认支持curl或者fsocket,联系您的空间商解决或者更换空间!", "30" => "密码错误", "40" => "账号不存在", "41" => "余额不足", "42" => "帐户已过期", "43" => "IP地址限制", "50" => "内容含有敏感词" ); $user = $this->_config['api_key']; //短信平台帐号 $pass = md5($this->_config['api_secret']); //短信平台密码 $content=$message->content;//要发送的短信内容 $phone = implode(',', $message->to);//要发送短信的手机号码 $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'); }} |
经过上面的替换,短信宝的短信平台已经替换成功了,可以正常使用了。进行测试发送:
报备一下短信宝的VIP模板,这样就可以走短信宝的优质通道了,即便遇到敏感文字我们都不会人工审核,短信内容3~5秒就可送达。
另外:我们已经开发好完整的Rhymix_V2.1.19系统短信宝插件,点击此链接 下载及查看安装流程。
最新更新
电商类
CMS类
微信类