@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | { |
| 41 | 41 | $url = $this->_options["url"]."?appId=".$this->_options["appid"]; |
| 42 | 42 | |
| 43 | - $url.= "¬ificationToken=".$notificationToken; |
|
| 43 | + $url .= "¬ificationToken=".$notificationToken; |
|
| 44 | 44 | |
| 45 | 45 | $ch = curl_init(); |
| 46 | 46 | |
@@ -53,12 +53,12 @@ discard block |
||
| 53 | 53 | $output = curl_exec($ch); |
| 54 | 54 | curl_close($ch); |
| 55 | 55 | |
| 56 | - if (stripos($output, "not found")!==false) { |
|
| 56 | + if (stripos($output, "not found") !== false) { |
|
| 57 | 57 | $this->logger->error('Token Exchange failed and responded with: not found', ['full output' => $output]); |
| 58 | 58 | return false; |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - if (stripos($output, "error")!==false) { |
|
| 61 | + if (stripos($output, "error") !== false) { |
|
| 62 | 62 | $this->logger->error('Token Exchange failed and responded with: error', ['full output' => $output]); |
| 63 | 63 | return false; |
| 64 | 64 | } |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | /** |
| 50 | 50 | * @throws Tiqr_Message_Exception_SendFailure |
| 51 | 51 | */ |
| 52 | - private function getGoogleAccessToken($credentialsFile, $cacheTokens, $tokenCacheDir ) |
|
| 52 | + private function getGoogleAccessToken($credentialsFile, $cacheTokens, $tokenCacheDir) |
|
| 53 | 53 | { |
| 54 | 54 | $client = new Google_Client(); |
| 55 | 55 | $client->setLogger($this->logger); |
@@ -61,8 +61,8 @@ discard block |
||
| 61 | 61 | $pool = new FilesystemCachePool($filesystem); |
| 62 | 62 | |
| 63 | 63 | //set up a callback to log token refresh |
| 64 | - $logger=$this->logger; |
|
| 65 | - $tokenCallback = function ($cacheKey, $accessToken) use ($logger) { |
|
| 64 | + $logger = $this->logger; |
|
| 65 | + $tokenCallback = function($cacheKey, $accessToken) use ($logger) { |
|
| 66 | 66 | $logger->info(sprintf('New access token received at cache key %s', $cacheKey)); |
| 67 | 67 | }; |
| 68 | 68 | $client->setTokenCallback($tokenCallback); |
@@ -94,9 +94,9 @@ discard block |
||
| 94 | 94 | * @param $retry boolean is this a 2nd attempt |
| 95 | 95 | * @throws Tiqr_Message_Exception_SendFailure |
| 96 | 96 | */ |
| 97 | - private function _sendFirebase(string $deviceToken, string $alert, string $challenge, string $projectId, string $credentialsFile, bool $cacheTokens, string $tokenCacheDir, bool $retry=false) |
|
| 97 | + private function _sendFirebase(string $deviceToken, string $alert, string $challenge, string $projectId, string $credentialsFile, bool $cacheTokens, string $tokenCacheDir, bool $retry = false) |
|
| 98 | 98 | { |
| 99 | - $apiurl = sprintf('https://fcm.googleapis.com/v1/projects/%s/messages:send',$projectId); |
|
| 99 | + $apiurl = sprintf('https://fcm.googleapis.com/v1/projects/%s/messages:send', $projectId); |
|
| 100 | 100 | |
| 101 | 101 | $fields = [ |
| 102 | 102 | 'message' => [ |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | |
| 114 | 114 | try { |
| 115 | 115 | $headers = array( |
| 116 | - 'Authorization: Bearer ' . $this->getGoogleAccessToken($credentialsFile, $cacheTokens, $tokenCacheDir), |
|
| 116 | + 'Authorization: Bearer '.$this->getGoogleAccessToken($credentialsFile, $cacheTokens, $tokenCacheDir), |
|
| 117 | 117 | 'Content-Type: application/json', |
| 118 | 118 | ); |
| 119 | 119 | } catch (\Google\Exception $e) { |
@@ -137,13 +137,13 @@ discard block |
||
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | if (!empty($errors)) { |
| 140 | - throw new Tiqr_Message_Exception_SendFailure("Http error occurred: ". $errors, true); |
|
| 140 | + throw new Tiqr_Message_Exception_SendFailure("Http error occurred: ".$errors, true); |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | // Wait and retry once in case of a 502 Bad Gateway error |
| 144 | 144 | if ($statusCode === 502 && !($retry)) { |
| 145 | 145 | sleep(2); |
| 146 | - $this->_sendFirebase($deviceToken, $alert, $challenge, $projectId, $credentialsFile, $cacheTokens, $tokenCacheDir, true); |
|
| 146 | + $this->_sendFirebase($deviceToken, $alert, $challenge, $projectId, $credentialsFile, $cacheTokens, $tokenCacheDir, true); |
|
| 147 | 147 | return; |
| 148 | 148 | } |
| 149 | 149 | |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | // handle errors, ignoring registration_id's |
| 155 | 155 | $response = json_decode($result, true); |
| 156 | 156 | foreach ($response as $k => $v) { |
| 157 | - if ($k=="error") { |
|
| 157 | + if ($k == "error") { |
|
| 158 | 158 | throw new Tiqr_Message_Exception_SendFailure(sprintf("Error in FCM response: %s", $result), true); |
| 159 | 159 | } |
| 160 | 160 | } |