From e583e7fa82b60a7886a6be18501542037fbe62de Mon Sep 17 00:00:00 2001 From: Yizack Rangel Date: Mon, 22 Jul 2024 01:50:14 -0500 Subject: [PATCH] chore: log warning on failed token refresh --- src/InstagramFeed.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/InstagramFeed.php b/src/InstagramFeed.php index 3f5b6f7..b14fcc6 100644 --- a/src/InstagramFeed.php +++ b/src/InstagramFeed.php @@ -29,7 +29,10 @@ protected function refreshToken() { $updatedDate = $updatedJson["updated"] ?? $date; if (strtotime($date) - strtotime($updatedDate) > self::TOKEN_REFRESH_INTERVAL) { - $this->fetch("https://graph.instagram.com/refresh_access_token?grant_type=ig_refresh_token&access_token=" . $this->getToken()); + $refresh = $this->fetch("https://graph.instagram.com/refresh_access_token?grant_type=ig_refresh_token&access_token=" . $this->getToken()); + if (!$refresh) { + error_log("Warning: Failed to refresh token, please check your configuration or generate a new token."); + } file_put_contents($filePath, json_encode($array)); } }