@@ -34,7 +34,7 @@ |
||
34 | 34 | |
35 | 35 | const ENDPOINT_FORMAT = 'json'; |
36 | 36 | |
37 | - const ENDPOINT_REGION = '86'; // 中国区,目前只支持此国别 |
|
37 | + const ENDPOINT_REGION = '86'; // 中国区,目前只支持此国别 |
|
38 | 38 | |
39 | 39 | const SUCCESS_CODE = 200; |
40 | 40 |
@@ -267,7 +267,7 @@ |
||
267 | 267 | |
268 | 268 | $name = \ucfirst(\str_replace(['-', '_', ''], '', $name)); |
269 | 269 | |
270 | - return __NAMESPACE__."\\Gateways\\{$name}Gateway"; |
|
270 | + return __NAMESPACE__."\\Gateways\\{$name}gateway"; |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | /** |
@@ -65,7 +65,7 @@ |
||
65 | 65 | 'tpl_id' => $template, |
66 | 66 | 'tpl_value' => implode('&', $data) |
67 | 67 | ]); |
68 | - }else{ |
|
68 | + } else{ |
|
69 | 69 | $content = $message->getContent($this); |
70 | 70 | $signature = $config->get('signature', ''); |
71 | 71 | $option['form_params'] = array_merge($option['form_params'],[ |
@@ -53,24 +53,24 @@ |
||
53 | 53 | 'exceptions' => false, |
54 | 54 | ]; |
55 | 55 | |
56 | - if(!is_null($template)){ |
|
56 | + if (!is_null($template)) { |
|
57 | 57 | $function = 'tpl_single_send'; |
58 | 58 | $data = []; |
59 | 59 | |
60 | 60 | $templateData = $message->getData($this); |
61 | 61 | $templateData = isset($templateData) ? $templateData : []; |
62 | 62 | foreach ($templateData as $key => $value) { |
63 | - $data[] = urlencode('#'.$key.'#') . '=' . urlencode($value); |
|
63 | + $data[] = urlencode('#'.$key.'#').'='.urlencode($value); |
|
64 | 64 | } |
65 | 65 | |
66 | - $option['form_params'] = array_merge($option['form_params'],[ |
|
66 | + $option['form_params'] = array_merge($option['form_params'], [ |
|
67 | 67 | 'tpl_id' => $template, |
68 | 68 | 'tpl_value' => implode('&', $data) |
69 | 69 | ]); |
70 | - }else{ |
|
70 | + } else { |
|
71 | 71 | $content = $message->getContent($this); |
72 | 72 | $signature = $config->get('signature', ''); |
73 | - $option['form_params'] = array_merge($option['form_params'],[ |
|
73 | + $option['form_params'] = array_merge($option['form_params'], [ |
|
74 | 74 | 'text' => 0 === \stripos($content, '【') ? $content : $signature.$content |
75 | 75 | ]); |
76 | 76 | } |
@@ -71,7 +71,7 @@ |
||
71 | 71 | */ |
72 | 72 | protected function getEndpointUrl($params) |
73 | 73 | { |
74 | - return self::ENDPOINT_URL . '?' . http_build_query($params); |
|
74 | + return self::ENDPOINT_URL.'?'.http_build_query($params); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | /** |
@@ -40,7 +40,7 @@ |
||
40 | 40 | public function send(PhoneNumberInterface $to, MessageInterface $message, Config $config) |
41 | 41 | { |
42 | 42 | $tKey = time(); |
43 | - $password = md5(md5($config->get('password')) . $tKey); |
|
43 | + $password = md5(md5($config->get('password')).$tKey); |
|
44 | 44 | $params = [ |
45 | 45 | 'username' => $config->get('username', ''), |
46 | 46 | 'password' => $password, |
@@ -41,12 +41,12 @@ |
||
41 | 41 | { |
42 | 42 | $time = time(); |
43 | 43 | $user_id = $config->get('user_id'); |
44 | - $token = md5($time . $user_id . $config->get('secret')); |
|
44 | + $token = md5($time.$user_id.$config->get('secret')); |
|
45 | 45 | $params = [ |
46 | 46 | 'user_id' => $user_id, |
47 | 47 | 'time' => $time, |
48 | 48 | 'token' => $token, |
49 | - 'mobiles' => $to->getNumber(),// 手机号码,多个英文逗号隔开 |
|
49 | + 'mobiles' => $to->getNumber(), // 手机号码,多个英文逗号隔开 |
|
50 | 50 | 'tpl_code' => $message->getTemplate($this), |
51 | 51 | 'tpl_params' => $message->getData($this), |
52 | 52 | 'sign_name' => $config->get('sign_name'), |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | |
58 | 58 | unset($data['sign_name']); |
59 | 59 | |
60 | - $phone = ($to->getIDDCode() ?: "+86"). $to->getNumber(); |
|
60 | + $phone = ($to->getIDDCode() ?: "+86").$to->getNumber(); |
|
61 | 61 | $params = [ |
62 | 62 | 'PhoneNumberSet' => [ |
63 | 63 | $phone |
@@ -103,18 +103,18 @@ discard block |
||
103 | 103 | $secretKey = $this->config->get('secret_key'); |
104 | 104 | $secretId = $this->config->get('secret_id'); |
105 | 105 | |
106 | - $canonicalRequest = 'POST'."\n". |
|
106 | + $canonicalRequest = 'POST'."\n". |
|
107 | 107 | '/'."\n". |
108 | - '' ."\n". |
|
108 | + ''."\n". |
|
109 | 109 | 'content-type:application/json; charset=utf-8'."\n". |
110 | - 'host:' . self::ENDPOINT_HOST."\n"."\n". |
|
110 | + 'host:'.self::ENDPOINT_HOST."\n"."\n". |
|
111 | 111 | 'content-type;host'."\n". |
112 | 112 | hash("SHA256", json_encode($params)); |
113 | 113 | |
114 | 114 | $stringToSign = |
115 | 115 | 'TC3-HMAC-SHA256'."\n". |
116 | 116 | $timestamp."\n". |
117 | - $date . '/'. self::ENDPOINT_SERVICE .'/tc3_request'."\n". |
|
117 | + $date.'/'.self::ENDPOINT_SERVICE.'/tc3_request'."\n". |
|
118 | 118 | hash("SHA256", $canonicalRequest); |
119 | 119 | |
120 | 120 | $secretDate = hash_hmac("SHA256", $date, "TC3".$secretKey, true); |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | $signature = hash_hmac("SHA256", $stringToSign, $secretSigning); |
124 | 124 | |
125 | 125 | return 'TC3-HMAC-SHA256' |
126 | - ." Credential=". $secretId ."/". $date . '/'. self::ENDPOINT_SERVICE .'/tc3_request' |
|
126 | + ." Credential=".$secretId."/".$date.'/'.self::ENDPOINT_SERVICE.'/tc3_request' |
|
127 | 127 | .", SignedHeaders=content-type;host, Signature=".$signature; |
128 | 128 | } |
129 | 129 | } |