From 90bc6bbc15c763e2bb31761a4b4dfd0ed32c047f Mon Sep 17 00:00:00 2001 From: Boudewijn van Breukelen Date: Fri, 2 Sep 2016 14:38:55 +0200 Subject: [PATCH 1/3] Fixed two errors on line 879 in isAccessTokenExpire method --- src/bitrix24.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bitrix24.php b/src/bitrix24.php index e894535d..5c52d3a0 100644 --- a/src/bitrix24.php +++ b/src/bitrix24.php @@ -876,7 +876,7 @@ public function isAccessTokenExpire() // $url = 'https://'.self::OAUTH_SERVER.'/rest/app.info?auth='.$accessToken; $url = 'https://' . $domain . '/rest/app.info?auth=' . $accessToken; $requestResult = $this->executeRequest($url); - if (in_array($requestResult['error'], array('expired_token', 'invalid_token', 'WRONG_TOKEN'), false)) { + if (isset($requestResult['error']) && in_array($requestResult['error'], array('EXPIRED_TOKEN', 'INVALID_TOKEN', 'WRONG_TOKEN'), false)) { $isTokenExpire = true; } else { // handle other errors @@ -1008,4 +1008,4 @@ public function getRetriesToConnectTimeout() { return $this->retriesToConnectTimeout; } -} \ No newline at end of file +} From 1261cf80fcbb80bd30113c6a5c3645199e0f35c7 Mon Sep 17 00:00:00 2001 From: Boudewijn van Breukelen Date: Fri, 2 Sep 2016 14:57:44 +0200 Subject: [PATCH 2/3] Modified fix to accept no errors --- src/bitrix24.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/bitrix24.php b/src/bitrix24.php index 5c52d3a0..9c122012 100644 --- a/src/bitrix24.php +++ b/src/bitrix24.php @@ -876,11 +876,13 @@ public function isAccessTokenExpire() // $url = 'https://'.self::OAUTH_SERVER.'/rest/app.info?auth='.$accessToken; $url = 'https://' . $domain . '/rest/app.info?auth=' . $accessToken; $requestResult = $this->executeRequest($url); - if (isset($requestResult['error']) && in_array($requestResult['error'], array('EXPIRED_TOKEN', 'INVALID_TOKEN', 'WRONG_TOKEN'), false)) { - $isTokenExpire = true; - } else { - // handle other errors - $this->handleBitrix24APILevelErrors($requestResult, 'app.info'); + if (isset($requestResult['error'])) { + if (in_array($requestResult['error'], array('EXPIRED_TOKEN', 'INVALID_TOKEN', 'WRONG_TOKEN'), false)) { + $isTokenExpire = true; + } else { + // handle other errors + $this->handleBitrix24APILevelErrors($requestResult, 'app.info'); + } } return $isTokenExpire; }// end of isTokenExpire From 1bec511360fe867a3d671cf3e99082bcf6a5af2d Mon Sep 17 00:00:00 2001 From: Boudewijn van Breukelen Date: Fri, 2 Sep 2016 16:59:08 +0200 Subject: [PATCH 3/3] Added if isset to catch no errors --- src/bitrix24.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bitrix24.php b/src/bitrix24.php index 9c122012..e7e95c71 100644 --- a/src/bitrix24.php +++ b/src/bitrix24.php @@ -877,7 +877,7 @@ public function isAccessTokenExpire() $url = 'https://' . $domain . '/rest/app.info?auth=' . $accessToken; $requestResult = $this->executeRequest($url); if (isset($requestResult['error'])) { - if (in_array($requestResult['error'], array('EXPIRED_TOKEN', 'INVALID_TOKEN', 'WRONG_TOKEN'), false)) { + if (in_array($requestResult['error'], array('expired_token', 'invalid_token', 'WRONG_TOKEN'), false)) { $isTokenExpire = true; } else { // handle other errors