@@ -41,8 +41,9 @@ |
||
| 41 | 41 | if (!$this->keep_alive) { |
| 42 | 42 | $this->curl = curl_init(); |
| 43 | 43 | } else { |
| 44 | - if ($this->curl == NULL) |
|
| 45 | - $this->curl = curl_init(); |
|
| 44 | + if ($this->curl == NULL) { |
|
| 45 | + $this->curl = curl_init(); |
|
| 46 | + } |
|
| 46 | 47 | } |
| 47 | 48 | |
| 48 | 49 | if ($this->curl == NULL) { |
@@ -41,12 +41,13 @@ discard block |
||
| 41 | 41 | |
| 42 | 42 | public function set_sign_method($sign_method = 'sha1') |
| 43 | 43 | { |
| 44 | - if ($sign_method == 'sha1' || $sign_method == 'HmacSHA256') |
|
| 45 | - $this->sign_method = 'HmacSHA1'; |
|
| 46 | - elseif ($sign_method == 'sha256') |
|
| 47 | - $this->sign_method = 'HmacSHA256'; |
|
| 48 | - else |
|
| 49 | - throw new CMQClientParameterException('Only support sign method HmasSHA256 or HmacSHA1 . Invalid sign method:' . $sign_method); |
|
| 44 | + if ($sign_method == 'sha1' || $sign_method == 'HmacSHA256') { |
|
| 45 | + $this->sign_method = 'HmacSHA1'; |
|
| 46 | + } elseif ($sign_method == 'sha256') { |
|
| 47 | + $this->sign_method = 'HmacSHA256'; |
|
| 48 | + } else { |
|
| 49 | + throw new CMQClientParameterException('Only support sign method HmasSHA256 or HmacSHA1 . Invalid sign method:' . $sign_method); |
|
| 50 | + } |
|
| 50 | 51 | |
| 51 | 52 | } |
| 52 | 53 | |
@@ -94,17 +95,21 @@ discard block |
||
| 94 | 95 | $_params['Action'] = ucfirst($action); |
| 95 | 96 | $_params['RequestClient'] = $this->version; |
| 96 | 97 | |
| 97 | - if (!isset($_params['SecretId'])) |
|
| 98 | - $_params['SecretId'] = $this->secretId; |
|
| 98 | + if (!isset($_params['SecretId'])) { |
|
| 99 | + $_params['SecretId'] = $this->secretId; |
|
| 100 | + } |
|
| 99 | 101 | |
| 100 | - if (!isset($_params['Nonce'])) |
|
| 101 | - $_params['Nonce'] = rand(1, 65535); |
|
| 102 | + if (!isset($_params['Nonce'])) { |
|
| 103 | + $_params['Nonce'] = rand(1, 65535); |
|
| 104 | + } |
|
| 102 | 105 | |
| 103 | - if (!isset($_params['Timestamp'])) |
|
| 104 | - $_params['Timestamp'] = time(); |
|
| 106 | + if (!isset($_params['Timestamp'])) { |
|
| 107 | + $_params['Timestamp'] = time(); |
|
| 108 | + } |
|
| 105 | 109 | |
| 106 | - if (!isset($_params['SignatureMethod'])) |
|
| 107 | - $_params['SignatureMethod'] = $this->sign_method; |
|
| 110 | + if (!isset($_params['SignatureMethod'])) { |
|
| 111 | + $_params['SignatureMethod'] = $this->sign_method; |
|
| 112 | + } |
|
| 108 | 113 | |
| 109 | 114 | $plainText = Signature::makeSignPlainText($_params, |
| 110 | 115 | $this->method, $this->host, $req_inter->uri); |