Update MediaService.php
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user