POST Video Stories using graph api facebook
hello guys im trying to automate a stories video post on facebook but dont know what im doing wrong, my picture stories function works fine but my video one is not working at all!!! i tried to look over here and documentation for a answer but couldnt find a solution! in the first 10 calls i was getting errors from graph and from now on i keep getting erro 500! does anyone knows what i can be doing wrong?
function postStoriesVideoFacebook($fb, $pageId, $pageAccessToken, $mediaUrls){ $mediaUrls = 'https://sample-videos.com/video123/mp4/720/big_buck_bunny_720p_1mb.mp4'; // Etapa 1: Inicializar a sessão de upload $response = $fb->post("/{$pageId}/video_stories", [ 'upload_phase' => 'start', ], $pageAccessToken); $initData = $response->getDecodedBody(); $videoId = $initData['video_id']; $uploadUrl = $initData['upload_url']; // Debugging - Verificando as variáveis var_dump($initData, $videoId, $uploadUrl); // Etapa 2: Fazer upload do vídeo usando a URL remota $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $uploadUrl); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_HTTPHEADER, [ "Authorization: OAuth $pageAccessToken", // Passando o token como OAuth "file_url: $mediaUrls" ]); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $uploadResponse = curl_exec($ch); curl_close($ch); $uploadData = json_decode($uploadResponse, true); // Debugging - Verificando a resposta do upload var_dump($uploadData); if (isset($uploadData['success']) && $uploadData['success'] === true) { // Etapa 3: Publicar o vídeo nos Stories $finishResponse = $fb->post("/{$pageId}/video_stories", [ 'upload_phase' => 'finish', 'video_id' => $videoId, ], $pageAccessToken); $result = $finishResponse->getDecodedBody(); // Debugging - Verificando a resposta da publicação var_dump($result); if (isset($result['success']) && $result['success'] === true) { return $result['post_id']; // Retorna o ID do post se a publicação for bem-sucedida } else { throw new Exception('Erro ao publicar o vídeo nos Stories.'); } } else { throw new Exception('Erro ao fazer upload do vídeo.'); } }
forums , using direct the cURL options, postman etc