From 3b018ece007bb0e34683aee3038799cec0383240 Mon Sep 17 00:00:00 2001 From: Claudio Ferraro Date: Mon, 6 Jan 2025 15:54:46 +0100 Subject: [PATCH] Compatibility with new Instagram API requirements --- src/Instagram.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/Instagram.php b/src/Instagram.php index b8d97c4..f7da4f2 100644 --- a/src/Instagram.php +++ b/src/Instagram.php @@ -1,9 +1,7 @@ client_id; $redirect = $this->redirectUriForProfile($profile->id); + $scopes = ['instagram_business_basic']; + + $parameters = [ + 'client_id' => $client_id, + 'redirect_uri' => $redirect, + 'response_type' => 'code', + 'scope' => urlencode(implode(',', $scopes)), + 'state' => $profile->identity_token, + ]; - return "https://api.instagram.com/oauth/authorize/?client_id=$client_id&redirect_uri=$redirect&scope=user_profile,user_media&response_type=code&state={$profile->identity_token}"; + return 'https://www.instagram.com/oauth/authorize/?' . http_build_query($parameters); } private function redirectUriForProfile($profile_id) @@ -65,7 +71,7 @@ public function requestTokenForProfile($profile, $auth_request) public function fetchUserDetails($access_token) { - $url = sprintf(self::GRAPH_USER_INFO_FORMAT, $access_token['user_id'], $access_token['access_token']); + $url = sprintf(self::GRAPH_USER_INFO_FORMAT, $access_token['access_token'] ?? $access_token['access_code']); return SimpleClient::get($url); }