Open-source social media scheduler built for AI agents and the teams behind them. Create, schedule and publish posts to every network through MCP or the REST API, or write them yourself in a composer your team will love.
PHP ai-agentsblueskyfacebookinstagramlaravellinkedinmastodonmcpmcp-serveropen-sourcerest-apiself-hostedsocial-mediasocial-media-managementsocial-media-schedulerthreadstiktokvuejsxyoutube
chore: remove verbose Log::info, add GD memory check, redact tokens in exception context
Paulo Castellano0cf84e4424d9
diff --git a/app/Services/Social/FacebookPublisher.php b/app/Services/Social/FacebookPublisher.phpindex 55531450a..4f476c013 100644--- a/app/Services/Social/FacebookPublisher.php+++ b/app/Services/Social/FacebookPublisher.php@@ -65,8 +65,6 @@ class FacebookPublisherprivate function publishTextPost(string $pageId, string $accessToken, string $content): array{- Log::info('Facebook publishing text post', ['page_id' => $pageId]);-$response = Http::post("{$this->baseUrl}/{$pageId}/feed", ['message' => $content,'access_token' => $accessToken,@@ -91,8 +89,6 @@ class FacebookPublisherprivate function publishSingleImagePost(string $pageId, string $accessToken, ?string $content, $media): array{- Log::info('Facebook publishing single image post', ['page_id' => $pageId]);-$response = Http::post("{$this->baseUrl}/{$pageId}/photos", ['message' => $content,'url' => $media->url,@@ -118,11 +114,6 @@ class FacebookPublisherprivate function publishMultiImagePost(string $pageId, string $accessToken, ?string $content, $mediaCollection): array{- Log::info('Facebook publishing multi-image post', [- 'page_id' => $pageId,- 'image_count' => $mediaCollection->count(),- ]);-// Upload each image as unpublished$attachedMedia = [];@@ -184,8 +175,6 @@ class FacebookPublisherprivate function publishVideoPost(string $pageId, string $accessToken, ?string $content, $media): array{- Log::info('Facebook publishing video post', ['page_id' => $pageId]);-// Use resumable upload for videos$response = Http::post("{$this->baseUrl}/{$pageId}/videos", ['description' => $content,@@ -212,8 +201,6 @@ class FacebookPublisherprivate function publishReel(string $pageId, string $accessToken, ?string $content, $media): array{- Log::info('Facebook publishing reel', ['page_id' => $pageId]);-// Upload video as reel$response = Http::post("{$this->baseUrl}/{$pageId}/video_reels", ['upload_phase' => 'start',@@ -272,8 +259,6 @@ class FacebookPublisherprivate function publishStory(string $pageId, string $accessToken, $media): array{- Log::info('Facebook publishing story', ['page_id' => $pageId]);-$isVideo = $media->isVideo();if ($isVideo) {diff --git a/app/Services/Social/InstagramPublisher.php b/app/Services/Social/InstagramPublisher.phpindex e216254a2..96c375f4c 100644--- a/app/Services/Social/InstagramPublisher.php+++ b/app/Services/Social/InstagramPublisher.php@@ -63,8 +63,6 @@ class InstagramPublisherprivate function publishSingleImage(string $instagramId, string $accessToken, ?string $content, $media): array{- Log::info('Instagram publishing single image', ['instagram_id' => $instagramId, 'image_url' => $media->url]);-// Step 1: Create container$containerResponse = Http::post("{$this->baseUrl}/{$instagramId}/media", ['image_url' => $media->url,@@ -72,11 +70,6 @@ class InstagramPublisher'access_token' => $accessToken,]);- Log::info('Instagram container response', [- 'status' => $containerResponse->status(),- 'body' => $containerResponse->json(),- ]);-if ($containerResponse->failed()) {Log::error('Instagram container creation failed', ['status' => $containerResponse->status(),@@ -100,8 +93,6 @@ class InstagramPublisherprivate function publishReel(string $instagramId, string $accessToken, ?string $content, $media): array{- Log::info('Instagram publishing reel', ['instagram_id' => $instagramId]);-// Step 1: Create container for video/reel$containerResponse = Http::post("{$this->baseUrl}/{$instagramId}/media", ['video_url' => $media->url,@@ -133,8 +124,6 @@ class InstagramPublisherprivate function publishStory(string $instagramId, string $accessToken, $media): array{- Log::info('Instagram publishing story', ['instagram_id' => $instagramId]);-$isVideo = $media->isVideo();$params = [@@ -174,11 +163,6 @@ class InstagramPublisherprivate function publishCarousel(string $instagramId, string $accessToken, ?string $content, $mediaCollection): array{- Log::info('Instagram publishing carousel', [- 'instagram_id' => $instagramId,- 'media_count' => $mediaCollection->count(),- ]);-// Step 1: Create containers for each media item$childContainers = [];@@ -274,8 +258,6 @@ class InstagramPublisher$permalink = $permalinkResponse->json()['permalink'] ?? null;- Log::info('Instagram publish success', ['media_id' => $mediaId, 'permalink' => $permalink]);-return ['id' => $mediaId,'url' => $permalink,@@ -298,8 +280,6 @@ class InstagramPublisher$status = $statusResponse->json()['status_code'] ?? 'UNKNOWN';- Log::info('Instagram media processing status', ['status' => $status, 'attempt' => $i]);-if ($status === 'FINISHED') {return;}@@ -336,7 +316,6 @@ class InstagramPublisher'token_expires_at' => data_get($data, 'expires_in') ? now()->addSeconds(data_get($data, 'expires_in')) : null,]);- Log::info('Instagram token refreshed successfully');}private function handleApiError(Response $response): neverdiff --git a/app/Services/Social/LinkedInPagePublisher.php b/app/Services/Social/LinkedInPagePublisher.phpindex 38026eb72..5d443505b 100644--- a/app/Services/Social/LinkedInPagePublisher.php+++ b/app/Services/Social/LinkedInPagePublisher.php@@ -68,10 +68,6 @@ class LinkedInPagePublisher$this->hasRetried = true;- Log::info('LinkedIn Page token rejected, attempting refresh and retry', [- 'account_id' => $this->account->id,- ]);-try {$this->refreshToken($this->account);$this->account->refresh();@@ -122,8 +118,6 @@ class LinkedInPagePublisher}}- Log::info('LinkedIn Page creating post', ['payload' => $payload]);-$response = $this->getHttpClient()->post("{$this->baseUrl}/rest/posts", $payload);@@ -151,11 +145,6 @@ class LinkedInPagePublisherprivate function publishCarousel(string $organizationUrn, ?string $content, $mediaCollection, $account): array{- Log::info('LinkedIn Page publishing carousel', [- 'owner' => $organizationUrn,- 'media_count' => $mediaCollection->count(),- ]);-// Upload images and build carousel items$carouselItems = [];@@ -195,8 +184,6 @@ class LinkedInPagePublisher],];- Log::info('LinkedIn Page creating carousel post', ['payload' => $payload]);-$response = $this->getHttpClient()->post("{$this->baseUrl}/rest/posts", $payload);@@ -252,8 +239,6 @@ class LinkedInPagePublisherprivate function uploadImage($mediaItem, string $ownerUrn): ?string{- Log::info('LinkedIn Page initializing image upload', ['owner' => $ownerUrn]);-// Step 1: Initialize upload$initResponse = $this->getHttpClient()->post("{$this->baseUrl}/rest/images?action=initializeUpload", [@@ -275,8 +260,6 @@ class LinkedInPagePublisherthrow new \Exception('LinkedIn Page image upload init missing uploadUrl or image URN');}- Log::info('LinkedIn Page image init success', ['imageUrn' => $imageUrn]);-// Step 2: Download and optimize image$tempFile = tempnam(sys_get_temp_dir(), 'lip_image_');@@ -305,8 +288,6 @@ class LinkedInPagePublisher$this->handleApiError($uploadResponse);}- Log::info('LinkedIn Page image upload success', ['imageUrn' => $imageUrn]);-return $imageUrn;} finally {@unlink($tempFile);@@ -330,11 +311,6 @@ class LinkedInPagePublisher$fileSize = (int) filesize($tempFile);- Log::info('LinkedIn Page initializing video upload', [- 'owner' => $ownerUrn,- 'fileSize' => $fileSize,- ]);-// Step 1: Initialize upload$initResponse = $this->getHttpClient()->post("{$this->baseUrl}/rest/videos?action=initializeUpload", [@@ -360,11 +336,6 @@ class LinkedInPagePublisherthrow new \Exception('LinkedIn Page video upload init missing video URN or upload instructions');}- Log::info('LinkedIn Page video init success', [- 'videoUrn' => $videoUrn,- 'chunks' => count($uploadInstructions),- ]);-// Step 2: Upload chunks$uploadedPartIds = [];$handle = fopen($tempFile, 'r');@@ -378,13 +349,6 @@ class LinkedInPagePublisherfseek($handle, $firstByte);$chunkData = fread($handle, $chunkLength);- Log::info('LinkedIn Page uploading video chunk', [- 'index' => $index,- 'firstByte' => $firstByte,- 'lastByte' => $lastByte,- 'chunkSize' => strlen($chunkData),- ]);-$chunkResponse = Http::withToken($this->accessToken)->withHeaders(['Content-Type' => 'application/octet-stream',@@ -406,14 +370,11 @@ class LinkedInPagePublisher$uploadedPartIds[] = $etag;}- Log::info('LinkedIn Page video chunk uploaded', ['index' => $index, 'etag' => $etag]);}fclose($handle);// Step 3: Finalize upload- Log::info('LinkedIn Page finalizing video upload', ['videoUrn' => $videoUrn]);-$finalizeResponse = $this->getHttpClient()->post("{$this->baseUrl}/rest/videos?action=finalizeUpload", ['finalizeUploadRequest' => [@@ -428,8 +389,6 @@ class LinkedInPagePublisher$this->handleApiError($finalizeResponse);}- Log::info('LinkedIn Page video upload finalized', ['videoUrn' => $videoUrn]);-// Step 4: Wait for processing$this->waitForVideoProcessing($videoUrn);@@ -454,8 +413,6 @@ class LinkedInPagePublisher$data = $response->json();$status = data_get($data, 'status', 'UNKNOWN');- Log::info('LinkedIn Page video processing status', ['status' => $status, 'attempt' => $i]);-if ($status === 'AVAILABLE') {return;}diff --git a/app/Services/Social/LinkedInPublisher.php b/app/Services/Social/LinkedInPublisher.phpindex 790d36307..37d81c89f 100644--- a/app/Services/Social/LinkedInPublisher.php+++ b/app/Services/Social/LinkedInPublisher.php@@ -62,10 +62,6 @@ class LinkedInPublisher$this->hasRetried = true;- Log::info('LinkedIn token rejected, attempting refresh and retry', [- 'account_id' => $this->account->id,- ]);-try {$this->refreshToken($this->account);$this->account->refresh();@@ -115,8 +111,6 @@ class LinkedInPublisher}}- Log::info('LinkedIn creating post', ['payload' => $payload]);-$response = $this->getHttpClient()->post("{$this->baseUrl}/rest/posts", $payload);@@ -138,11 +132,6 @@ class LinkedInPublisherprivate function publishCarousel(string $personUrn, ?string $content, $mediaCollection): array{- Log::info('LinkedIn publishing carousel', [- 'owner' => $personUrn,- 'media_count' => $mediaCollection->count(),- ]);-// Upload images and build carousel items$carouselItems = [];@@ -182,8 +171,6 @@ class LinkedInPublisher],];- Log::info('LinkedIn creating carousel post', ['payload' => $payload]);-$response = $this->getHttpClient()->post("{$this->baseUrl}/rest/posts", $payload);@@ -233,8 +220,6 @@ class LinkedInPublisherprivate function uploadImage($mediaItem, string $ownerUrn): ?string{- Log::info('LinkedIn initializing image upload', ['owner' => $ownerUrn]);-// Step 1: Initialize upload$initResponse = $this->getHttpClient()->post("{$this->baseUrl}/rest/images?action=initializeUpload", [@@ -256,8 +241,6 @@ class LinkedInPublisherthrow new \Exception('LinkedIn image upload init missing uploadUrl or image URN');}- Log::info('LinkedIn image init success', ['imageUrn' => $imageUrn]);-// Step 2: Download and optimize image$tempFile = tempnam(sys_get_temp_dir(), 'li_image_');@@ -286,8 +269,6 @@ class LinkedInPublisher$this->handleApiError($uploadResponse);}- Log::info('LinkedIn image upload success', ['imageUrn' => $imageUrn]);-return $imageUrn;} finally {@unlink($tempFile);@@ -311,11 +292,6 @@ class LinkedInPublisher$fileSize = (int) filesize($tempFile);- Log::info('LinkedIn initializing video upload', [- 'owner' => $ownerUrn,- 'fileSize' => $fileSize,- ]);-// Step 1: Initialize upload$initResponse = $this->getHttpClient()->post("{$this->baseUrl}/rest/videos?action=initializeUpload", [@@ -341,11 +317,6 @@ class LinkedInPublisherthrow new \Exception('LinkedIn video upload init missing video URN or upload instructions');}- Log::info('LinkedIn video init success', [- 'videoUrn' => $videoUrn,- 'chunks' => count($uploadInstructions),- ]);-// Step 2: Upload chunks$uploadedPartIds = [];$handle = fopen($tempFile, 'r');@@ -359,13 +330,6 @@ class LinkedInPublisherfseek($handle, $firstByte);$chunkData = fread($handle, $chunkLength);- Log::info('LinkedIn uploading video chunk', [- 'index' => $index,- 'firstByte' => $firstByte,- 'lastByte' => $lastByte,- 'chunkSize' => strlen($chunkData),- ]);-$chunkResponse = Http::withToken($this->accessToken)->withHeaders(['Content-Type' => 'application/octet-stream',@@ -387,14 +351,11 @@ class LinkedInPublisher$uploadedPartIds[] = $etag;}- Log::info('LinkedIn video chunk uploaded', ['index' => $index, 'etag' => $etag]);}fclose($handle);// Step 3: Finalize upload- Log::info('LinkedIn finalizing video upload', ['videoUrn' => $videoUrn]);-$finalizeResponse = $this->getHttpClient()->post("{$this->baseUrl}/rest/videos?action=finalizeUpload", ['finalizeUploadRequest' => [@@ -409,8 +370,6 @@ class LinkedInPublisher$this->handleApiError($finalizeResponse);}- Log::info('LinkedIn video upload finalized', ['videoUrn' => $videoUrn]);-// Step 4: Wait for processing$this->waitForVideoProcessing($videoUrn);@@ -435,8 +394,6 @@ class LinkedInPublisher$data = $response->json();$status = data_get($data, 'status', 'UNKNOWN');- Log::info('LinkedIn video processing status', ['status' => $status, 'attempt' => $i]);-if ($status === 'AVAILABLE') {return;}diff --git a/app/Services/Social/TikTokPublisher.php b/app/Services/Social/TikTokPublisher.phpindex 06419ca9b..0243eab58 100644--- a/app/Services/Social/TikTokPublisher.php+++ b/app/Services/Social/TikTokPublisher.php@@ -93,12 +93,6 @@ class TikTokPublisherprivate function publishVideo(PostPlatform $postPlatform, $media): array{- Log::info('TikTok publishing video', [- 'video_url' => $media->url,- 'media_full_url' => $media->full_url ?? $media->url,- 'content' => $postPlatform->content,- ]);-$creatorInfo = $this->queryCreatorInfo();$response = $this->getHttpClient()@@ -126,8 +120,6 @@ class TikTokPublisher$data = $response->json();- Log::info('TikTok video init response', ['data' => $data]);-$publishId = data_get($data, 'data.publish_id');if (! $publishId) {@@ -155,12 +147,6 @@ class TikTokPublisherthrow new \Exception('No valid images found for TikTok photo post');}- Log::info('TikTok publishing photos', [- 'photo_urls' => $photoUrls,- 'photo_count' => count($photoUrls),- 'content' => $postPlatform->content,- ]);-$creatorInfo = $this->queryCreatorInfo();$response = $this->getHttpClient()@@ -189,8 +175,6 @@ class TikTokPublisher$data = $response->json();- Log::info('TikTok photo init response', ['data' => $data]);-$publishId = data_get($data, 'data.publish_id');if (! $publishId) {@@ -228,12 +212,6 @@ class TikTokPublisher$data = $response->json();$status = data_get($data, 'data.status', 'UNKNOWN');- Log::info('TikTok publish status', [- 'status' => $status,- 'attempt' => $i,- 'data' => $data,- ]);-if ($status === 'PUBLISH_COMPLETE') {return data_get($data, 'data', []);}@@ -288,7 +266,6 @@ class TikTokPublisher'token_expires_at' => data_get($data, 'expires_in') ? now()->addSeconds(data_get($data, 'expires_in')) : null,]);- Log::info('TikTok token refreshed successfully');}private function handleApiError(Response $response): neverdiff --git a/app/Services/Social/XPublisher.php b/app/Services/Social/XPublisher.phpindex 351a62543..6fef7b57a 100644--- a/app/Services/Social/XPublisher.php+++ b/app/Services/Social/XPublisher.php@@ -44,15 +44,8 @@ class XPublisherif ($media->isNotEmpty()) {foreach ($media as $mediaItem) {- Log::info('Uploading media to X', [- 'url' => $mediaItem->url,- 'mime_type' => $mediaItem->mime_type,- ]);-$uploadedMedia = $this->uploadMedia($mediaItem);- Log::info('X media upload response', ['response' => $uploadedMedia]);-// v2 API returns data.id, v1 returns media_id$mediaId = data_get($uploadedMedia, 'data.id', data_get($uploadedMedia, 'media_id'));if ($mediaId) {@@ -71,8 +64,6 @@ class XPublisherthrow new \Exception('X posts require either text or media. Please add content to your post.');}- Log::info('Posting tweet', ['data' => $data]);-$response = $this->getHttpClient()->post("{$this->baseUrl}/2/tweets", $data);@@ -175,12 +166,6 @@ class XPublisherprivate function chunkedUpload(string $tempFile, int $totalBytes, string $mimeType, string $mediaCategory): array{- Log::info('X chunked upload INIT', [- 'total_bytes' => $totalBytes,- 'media_type' => $mimeType,- 'media_category' => $mediaCategory,- ]);-// INIT$initResponse = Http::withToken($this->accessToken)->timeout(60)@@ -205,8 +190,6 @@ class XPublisherthrow new \Exception('No media_id returned from INIT');}- Log::info('X chunked upload INIT success', ['media_id' => $mediaId]);-// APPEND - Read from temp file in 5MB chunks (memory-safe)$chunkSize = 5 * 1024 * 1024;$handle = fopen($tempFile, 'r');@@ -219,12 +202,6 @@ class XPublisherbreak;}- Log::info('X chunked upload APPEND', [- 'media_id' => $mediaId,- 'segment' => $index,- 'chunk_size' => strlen($chunk),- ]);-$appendResponse = Http::withToken($this->accessToken)->timeout(300)->attach('media', $chunk, 'chunk'.$index)@@ -247,8 +224,6 @@ class XPublisherfclose($handle);// FINALIZE - Use the new v2 endpoint- Log::info('X chunked upload FINALIZE', ['media_id' => $mediaId]);-$finalizeResponse = Http::withToken($this->accessToken)->timeout(60)->post("{$this->baseUrl}/2/media/upload/{$mediaId}/finalize");diff --git a/app/Services/Social/YouTubePublisher.php b/app/Services/Social/YouTubePublisher.phpindex 1c6e8b58f..5d35230a9 100644--- a/app/Services/Social/YouTubePublisher.php+++ b/app/Services/Social/YouTubePublisher.php@@ -79,11 +79,6 @@ class YouTubePublisher$title = $this->buildTitle($postPlatform->content);$description = $postPlatform->content;- Log::info('YouTube Shorts publishing video', [- 'video_url' => $media->url,- 'title' => $title,- ]);-$tempFile = tempnam(sys_get_temp_dir(), 'yt_upload_');$handle = null;@@ -103,8 +98,6 @@ class YouTubePublisherthrow new \Exception('Downloaded video is too small or empty ('.$fileSize.' bytes), aborting upload');}- Log::info('YouTube video downloaded', ['size' => $fileSize]);-// Set up Google Client with deferred mode for resumable upload$client = $this->createGoogleClient($account);$client->setDefer(true);@@ -162,8 +155,6 @@ class YouTubePublisher$videoId = $uploadStatus->getId();- Log::info('YouTube upload success', ['video_id' => $videoId]);-return ['id' => $videoId,'url' => "https://www.youtube.com/shorts/{$videoId}",@@ -229,7 +220,6 @@ class YouTubePublisher'token_expires_at' => data_get($data, 'expires_in') ? now()->addSeconds(data_get($data, 'expires_in')) : null,]);- Log::info('YouTube token refreshed successfully');}private function handleGoogleError(\Google\Service\Exception $e): never