From 82316df470fb8cd353b05a50762c373fb2d79c2e Mon Sep 17 00:00:00 2001 From: Paulo Castellano Date: Tue, 20 Jan 2026 18:51:18 -0300 Subject: [PATCH] feat: improvements on pinterest --- app/Services/Social/PinterestPublisher.php | 21 ++++++++------------- config/services.php | 1 - 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/app/Services/Social/PinterestPublisher.php b/app/Services/Social/PinterestPublisher.php index a8580836..df345a85 100644 --- a/app/Services/Social/PinterestPublisher.php +++ b/app/Services/Social/PinterestPublisher.php @@ -12,12 +12,7 @@ class PinterestPublisher { - private function getApiBase(): string - { - return config('services.pinterest.sandbox', false) - ? 'https://api-sandbox.pinterest.com/v5' - : 'https://api.pinterest.com/v5'; - } + private const API_BASE = 'https://api.pinterest.com/v5'; /** * Pinterest API error codes that indicate token issues. @@ -90,7 +85,7 @@ private function publishImagePin(PostPlatform $postPlatform): array } $response = Http::withToken($account->access_token) - ->post($this->getApiBase().'/pins', $payload); + ->post(self::API_BASE.'/pins', $payload); if ($response->failed()) { Log::error('Pinterest pin creation failed', [ @@ -132,7 +127,7 @@ private function publishVideoPin(PostPlatform $postPlatform): array // Step 1: Register media upload $registerResponse = Http::withToken($account->access_token) - ->post($this->getApiBase().'/media', [ + ->post(self::API_BASE.'/media', [ 'media_type' => 'video', ]); @@ -217,7 +212,7 @@ private function publishVideoPin(PostPlatform $postPlatform): array } $response = Http::withToken($account->access_token) - ->post($this->getApiBase().'/pins', $payload); + ->post(self::API_BASE.'/pins', $payload); if ($response->failed()) { Log::error('Pinterest video pin creation failed', [ @@ -283,7 +278,7 @@ private function publishCarousel(PostPlatform $postPlatform): array } $response = Http::withToken($account->access_token) - ->post($this->getApiBase().'/pins', $payload); + ->post(self::API_BASE.'/pins', $payload); if ($response->failed()) { Log::error('Pinterest carousel creation failed', [ @@ -307,7 +302,7 @@ private function waitForMediaProcessing(SocialAccount $account, string $mediaId, { for ($i = 0; $i < $maxAttempts; $i++) { $response = Http::withToken($account->access_token) - ->get($this->getApiBase()."/media/{$mediaId}"); + ->get(self::API_BASE."/media/{$mediaId}"); if ($response->failed()) { Log::warning('Pinterest media status check failed', [ @@ -353,7 +348,7 @@ public function refreshToken(SocialAccount $account): void config('services.pinterest.client_id'), config('services.pinterest.client_secret') ) - ->post($this->getApiBase().'/oauth/token', [ + ->post(self::API_BASE.'/oauth/token', [ 'grant_type' => 'refresh_token', 'refresh_token' => $account->refresh_token, ]); @@ -385,7 +380,7 @@ public function getBoards(SocialAccount $account): array } $response = Http::withToken($account->access_token) - ->get($this->getApiBase().'/boards', [ + ->get(self::API_BASE.'/boards', [ 'page_size' => 100, ]); diff --git a/config/services.php b/config/services.php index 470d7751..ec1fc652 100644 --- a/config/services.php +++ b/config/services.php @@ -93,7 +93,6 @@ 'client_id' => env('PINTEREST_CLIENT_ID'), 'client_secret' => env('PINTEREST_CLIENT_SECRET'), 'redirect' => env('PINTEREST_CLIENT_REDIRECT'), - 'sandbox' => env('PINTEREST_SANDBOX', false), ], ];