|
@@ -32,11 +32,11 @@ discard block |
|
|
block discarded – undo |
|
32
|
32
|
public function send(PhoneNumberInterface $to, MessageInterface $message, Config $config) |
|
33
|
33
|
{ |
|
34
|
34
|
$data = $message->getData($this); |
|
35
|
|
- $endpoint = self::ENDPOINT_HOST . '/sms/api/v1'; |
|
|
35
|
+ $endpoint = self::ENDPOINT_HOST.'/sms/api/v1'; |
|
36
|
36
|
return $this->execute($endpoint, [ |
|
37
|
|
- 'phoneNumber' => (string)$to, |
|
|
37
|
+ 'phoneNumber' => (string) $to, |
|
38
|
38
|
'templateCode' => $this->config->get('template_code'), |
|
39
|
|
- 'templateParam' => '{"code":"' . $data['code'] . '"}', |
|
|
39
|
+ 'templateParam' => '{"code":"'.$data['code'].'"}', |
|
40
|
40
|
'signName' => $this->config->get('sign_name'), |
|
41
|
41
|
'action' => 'SendSms' |
|
42
|
42
|
]); |
|
@@ -50,13 +50,13 @@ discard block |
|
|
block discarded – undo |
|
50
|
50
|
*/ |
|
51
|
51
|
protected function execute(string $url, array $data) |
|
52
|
52
|
{ |
|
53
|
|
- $uuid = date('ymdHis', time()) . substr(microtime(), 2, 6) . sprintf('%03d', rand(0, 999)); |
|
54
|
|
- $time = date('Ymd', time()) . 'T' . date('His') . 'Z'; |
|
|
53
|
+ $uuid = date('ymdHis', time()).substr(microtime(), 2, 6).sprintf('%03d', rand(0, 999)); |
|
|
54
|
+ $time = date('Ymd', time()).'T'.date('His').'Z'; |
|
55
|
55
|
$timeDate = substr($time, 0, 8); |
|
56
|
56
|
|
|
57
|
57
|
$body = bin2hex(hash("sha256", json_encode($data), true)); |
|
58
|
58
|
$query = ''; |
|
59
|
|
- $strSignature = "ctyun-eop-request-id:" . $uuid . "\n" . "eop-date:" . $time . "\n" . "\n" . $query . "\n" . $body; |
|
|
59
|
+ $strSignature = "ctyun-eop-request-id:".$uuid."\n"."eop-date:".$time."\n"."\n".$query."\n".$body; |
|
60
|
60
|
|
|
61
|
61
|
$kTime = $this->sha256($time, $this->config->get('secret_key')); |
|
62
|
62
|
$kAk = $this->sha256($this->config->get('access_key'), $kTime); |
|
@@ -66,7 +66,7 @@ discard block |
|
|
block discarded – undo |
|
66
|
66
|
$signature = base64_encode($this->sha256(($strSignature), $kDate)); |
|
67
|
67
|
$headers['Content-Type'] = 'application/json'; |
|
68
|
68
|
$headers['ctyun-eop-request-id'] = $uuid; |
|
69
|
|
- $headers['Eop-Authorization'] = $this->config->get('access_key') . ' Headers=ctyun-eop-request-id;' . 'eop-date Signature=' . $signature; |
|
|
69
|
+ $headers['Eop-Authorization'] = $this->config->get('access_key').' Headers=ctyun-eop-request-id;'.'eop-date Signature='.$signature; |
|
70
|
70
|
$headers['eop-date'] = $time; |
|
71
|
71
|
|
|
72
|
72
|
$result = $this->postJson($url, $data, $headers); |