Skip to content

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.

fix: revert Facebook Reel/Story to URL pull (video_file_chunk as URL) — binary upload was breaking the transfer phase

Paulo Castellano7aaaf4df4f03
diff --git a/app/Services/Social/FacebookPublisher.php b/app/Services/Social/FacebookPublisher.php
index 68f501b90..6efe02132 100644
--- a/app/Services/Social/FacebookPublisher.php
+++ b/app/Services/Social/FacebookPublisher.php
@@ -9,7 +9,6 @@ use App\Exceptions\Social\FacebookPublishException;
use App\Models\PostPlatform;
use App\Services\Social\Concerns\HasSocialHttpClient;
use Illuminate\Http\Client\Response;
-use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
class FacebookPublisher
@@ -225,34 +224,16 @@ class FacebookPublisher
$data = $response->json();
$videoId = data_get($data, 'video_id');
- // Upload the video file
- $tempFile = tempnam(sys_get_temp_dir(), 'fb_reel_');
- try {
- $downloadResponse = Http::withOptions(['sink' => $tempFile])->timeout(600)->get($media->url);
-
- if ($downloadResponse->failed()) {
- throw new \Exception('Failed to download media: HTTP '.$downloadResponse->status());
- }
-
- $stream = fopen($tempFile, 'r');
-
- $uploadResponse = Http::withToken($accessToken)
- ->attach('video_file_chunk', $stream, 'video.mp4')
- ->post("{$this->baseUrl}/{$videoId}", [
- 'upload_phase' => 'transfer',
- 'access_token' => $accessToken,
- ]);
-
- if (is_resource($stream)) {
- fclose($stream);
- }
+ // Upload the video file (Facebook accepts URL in video_file_chunk)
+ $uploadResponse = $this->socialHttp()->post("{$this->baseUrl}/{$videoId}", [
+ 'upload_phase' => 'transfer',
+ 'video_file_chunk' => $media->url,
+ 'access_token' => $accessToken,
+ ]);
- if ($uploadResponse->failed()) {
- Log::error('Facebook reel upload transfer failed', ['body' => $this->redactResponseBody($uploadResponse->body())]);
- $this->handleApiError($uploadResponse);
- }
- } finally {
- @unlink($tempFile);
+ if ($uploadResponse->failed()) {
+ Log::error('Facebook reel upload transfer failed', ['body' => $this->redactResponseBody($uploadResponse->body())]);
+ $this->handleApiError($uploadResponse);
}
// Finish and publish the reel
@@ -301,34 +282,16 @@ class FacebookPublisher
throw new \Exception('Facebook story upload failed: no video ID returned');
}
- // Transfer the video
- $tempFile = tempnam(sys_get_temp_dir(), 'fb_story_');
- try {
- $downloadResponse = Http::withOptions(['sink' => $tempFile])->timeout(600)->get($media->url);
-
- if ($downloadResponse->failed()) {
- throw new \Exception('Failed to download media: HTTP '.$downloadResponse->status());
- }
-
- $stream = fopen($tempFile, 'r');
-
- $transferResponse = Http::withToken($accessToken)
- ->attach('video_file_chunk', $stream, 'video.mp4')
- ->post("{$this->baseUrl}/{$videoId}", [
- 'upload_phase' => 'transfer',
- 'access_token' => $accessToken,
- ]);
-
- if (is_resource($stream)) {
- fclose($stream);
- }
-
- if ($transferResponse->failed()) {
- Log::error('Facebook video story transfer failed', ['body' => $this->redactResponseBody($transferResponse->body())]);
- $this->handleApiError($transferResponse);
- }
- } finally {
- @unlink($tempFile);
+ // Transfer the video (Facebook accepts URL in video_file_chunk)
+ $transferResponse = $this->socialHttp()->post("{$this->baseUrl}/{$videoId}", [
+ 'upload_phase' => 'transfer',
+ 'video_file_chunk' => $media->url,
+ 'access_token' => $accessToken,
+ ]);
+
+ if ($transferResponse->failed()) {
+ Log::error('Facebook video story transfer failed', ['body' => $this->redactResponseBody($transferResponse->body())]);
+ $this->handleApiError($transferResponse);
}
// Finish the story
diff --git a/resources/views/auth/social-callback.blade.php b/resources/views/auth/social-callback.blade.php
index eb7b68bad..13bdb7535 100644
--- a/resources/views/auth/social-callback.blade.php
+++ b/resources/views/auth/social-callback.blade.php
@@ -75,7 +75,7 @@
}
// Close after a short delay
- setTimeout(closeWindow, 6000);
+ setTimeout(closeWindow, 2000);
// If still open after 2 seconds, show manual close message
setTimeout(function() {