Ver Mensaje Individual
  #1 (permalink)  
Antiguo 27/07/2020, 14:37
Avatar de Middrel
Middrel
 
Fecha de Ingreso: abril-2005
Mensajes: 835
Antigüedad: 19 años
Puntos: 27
Importar XML con PHP

Hola, buenas tardes.

Como el titulo dice, estoy tratando de importar un archivo xml, obtenido de un sitio de podcast, para posteriormente utilizarlo en otro sitio de podcast. Para ello, estoy desarrollando un método de importación y carga.

He estado revisando varios tutoriales y guías y al parecer ya está funcionando bien, sin embargo hay un pequeño detalle...

Este es mi código hasta el momento:

Código PHP:
if(isset($_POST['upload-rss'])){
        
        
$xml trim(mysqli_real_escape_string($conn$_POST['url-rss']));        
        
$parse simplexml_load_file($xml); 
        
        
// Cabeceras del Show
        
foreach ($parse -> children() as $row) {
            
$title          $row -> title;
            
$description    $row -> description;            
            
            
$author         $row -> author;
            
$keywords       $row -> keywords;
            
$language       $row -> language;
            
$link           $row -> link;
            
$banner         $row -> image;
        }
        
        
// Obtener items de iTunes
        
$x simplexml_load_file($xml);
        
$path 'images/tmp/';

        foreach (
$x->channel->item as $item) { 
            
$otherNode $item->children('itunes'TRUE); 
            
$itunesTitle    $otherNode->title '<br>';
            
$itunesEpisode  $otherNode->episode '<br>';
            
$itunesAuthor   $otherNode->author '<br>'
            
$itunesSummary  $otherNode->summary '<br>';
            
$itunesKeywords $otherNode->keywords '<br>';
                    
            
            
$img $otherNode->image->attributes();
            
$ext substr($img, -33);
            
$permitted_chars '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
            
$imgName 'img-' substr(str_shuffle($permitted_chars), 016) . '.' $ext;
              
            
file_put_contents($path $imgName$img);            
        }                       
    } 
Al final, cuando importo la imagen o caratula que esta usando cada item, le cambio el nombre por uno aleatorio y las descargo en una carpeta temporal. Sin embargo, cuando bajo las imágenes, estas bajan de tamaño de 1kb y cuando intento verlas, me muestra:

Cita:
"Parece que el formato de este archivo no es compatible".
¿Saben en dónde me pueda estar equivocando? De antemano, gracias por sus comentarios.

Saludos!