1 | <?php |
||
12 | class AliyunSmsAgent extends Agent |
||
13 | { |
||
14 | public function sendSms($to, $content, $tempId, array $data) |
||
18 | |||
19 | public function sendTemplateSms($to, $tempId, array $data) |
||
30 | |||
31 | public function voiceVerify($to, $code, $tempId, array $data) |
||
34 | |||
35 | protected function request(array $params) |
||
42 | |||
43 | protected function createParams(array $params) |
||
44 | { |
||
45 | date_default_timezone_set('GMT'); |
||
46 | $params = array_merge([ |
||
47 | 'Format' => 'JSON', |
||
48 | 'Version' => '2016-09-27', |
||
49 | 'AccessKeyId' => $this->accessKeyId, |
||
50 | 'SignatureMethod' => 'HMAC-SHA1', |
||
51 | 'Timestamp' => date('Y-m-d\TH:i:s\Z'), |
||
52 | 'SignatureVersion' => '1.0', |
||
53 | 'SignatureNonce' => uniqid(), |
||
54 | ], $params); |
||
55 | $params['Signature'] = $this->computeSignature($params); |
||
56 | |||
57 | return $params; |
||
58 | } |
||
59 | |||
60 | private function computeSignature($parameters) |
||
61 | { |
||
62 | ksort($parameters); |
||
63 | $canonicalizedQueryString = ''; |
||
64 | foreach ($parameters as $key => $value) { |
||
65 | $canonicalizedQueryString .= '&' . $this->percentEncode($key) . '=' . $this->percentEncode($value); |
||
66 | } |
||
67 | $stringToSign = 'POST&%2F&' . $this->percentencode(substr($canonicalizedQueryString, 1)); |
||
68 | $signature = base64_encode(hash_hmac('sha1', $stringToSign, $this->accessKeySecret . '&', true)); |
||
69 | |||
70 | return $signature; |
||
71 | } |
||
72 | |||
73 | protected function percentEncode($str) |
||
74 | { |
||
75 | $res = urlencode($str); |
||
76 | $res = preg_replace('/\+/', '%20', $res); |
||
77 | $res = preg_replace('/\*/', '%2A', $res); |
||
78 | $res = preg_replace('/%7E/', '~', $res); |
||
79 | |||
80 | return $res; |
||
81 | } |
||
82 | |||
83 | protected function setResult($result) |
||
100 | |||
101 | protected function getTempDataString(array $data) |
||
109 | |||
110 | public function sendContentSms($to, $content) |
||
113 | } |
||
114 |
Since your code implements the magic getter
_get
, this function will be called for any read access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.