apiVersion = config('social.providers.meta.api_version', 'v18.0'); } public static function identifier(): string { return 'meta'; } public static function name(): string { return 'Meta'; } public function getAuthUrl(): string { $params = [ 'client_id' => $this->clientId, 'redirect_uri' => $this->redirectUrl, 'scope' => implode(',', $this->scopes), 'state' => $this->values['state'] ?? '', 'response_type' => 'code', ]; return $this->buildUrl(self::API_URL."/{$this->apiVersion}/dialog/oauth", $params); } public function requestAccessToken(array $params = []): array { $response = $this->http() ->post(self::API_URL."/{$this->apiVersion}/oauth/access_token", [ 'client_id' => $this->clientId, 'client_secret' => $this->clientSecret, 'redirect_uri' => $this->redirectUrl, 'code' => $params['code'], ]) ->json(); if (isset($response['error'])) { return [ 'error' => $response['error']['message'] ?? 'Unknown error', ]; } // Exchange for long-lived token $longLivedResponse = $this->http() ->get(self::API_URL."/{$this->apiVersion}/oauth/access_token", [ 'grant_type' => 'fb_exchange_token', 'client_id' => $this->clientId, 'client_secret' => $this->clientSecret, 'fb_exchange_token' => $response['access_token'], ]) ->json(); $expiresIn = $longLivedResponse['expires_in'] ?? 5184000; // 60 days default return [ 'access_token' => $longLivedResponse['access_token'] ?? $response['access_token'], 'expires_in' => Carbon::now('UTC')->addSeconds($expiresIn)->timestamp, 'token_type' => $longLivedResponse['token_type'] ?? 'bearer', ]; } public function getAccount(): Response { return $this->error('Use Read class with token for account info'); } }