diff --git a/classes/MediaService.php b/classes/MediaService.php index 855686a..bc5cda4 100644 --- a/classes/MediaService.php +++ b/classes/MediaService.php @@ -61,11 +61,11 @@ class MediaService { $mediaUrl = $decoded['url'] ?? ($decoded['data'][0]['url'] ?? null); if (!$mediaUrl) throw new Exception('No media url from Graph'); - // Descargar contenido: primero wget (más confiable con Facebook CDN), luego curl como fallback - $content = $this->downloadWithWget($mediaUrl, !empty($this->token) ? ['Authorization: Bearer ' . $this->token] : []); + // Descargar contenido usando cascade robusto (curl, file_get_contents, shell/proc/wget) + $content = $this->downloadUrl($mediaUrl); if ($content === false) { // Obtener URL fresca del Graph API (la anterior puede haber expirado tras el intento fallido) - error_log("[MediaService] wget download failed, getting fresh URL..."); + error_log("[MediaService] downloadUrl failed, getting fresh URL..."); $resp2 = $this->graphApiRequest($endpoint); if ($resp2) { $decoded2 = json_decode($resp2, true); @@ -73,7 +73,6 @@ class MediaService { } else { $freshUrl = $mediaUrl; } - $content = $this->downloadUrl($freshUrl); } if ($content === false) throw new Exception('Failed to download media content from ' . $mediaUrl);