Ver Mensaje Individual
  #1 (permalink)  
Antiguo 22/06/2012, 13:14
aguiacir
 
Fecha de Ingreso: junio-2012
Ubicación: Mexico DF
Mensajes: 16
Antigüedad: 12 años, 8 meses
Puntos: 1
Pregunta Sacar RSS con PHP

Hola encontre este codigo. Es para sacar los datos RSS.
Ya lo "modifique" y tambien hice la conexion, ero me manda un error. Alguien me podria ayudar.

Código PHP:
<?php
    
/*include("classes/class.inputfilter.php"); // input cleansing
      include("includes/includes.php");*/
    
include ("connection.php");
           
    
//select * form rssFeeds where approved = 1 AND user is active AND Users.active = 1"
    
$sql "SELECT * FROM RSS";
    
$query mysql_query($sql);
    
//echo "conectado";
    //And we display the results
    
while($result mysql_fetch_array($query)){
        
$result['url']=$rssFeed;
        
//$feedID = $result['ndx'];
        //$uid = $result['uid'];
    //echo "leo rss";
        
$doc = new DOMDocument();
        
//go fetch the feed and create array
        
$doc->loadXML('$rssFeed');
        
$arrFeeds = array();
        
//loop though the array
        
foreach ($doc->getElementsByTagName('item') as $node) {
            
$itemRSS = array (
                
'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
                
'desc' => $node->getElementsByTagName('description')->item(0)->nodeValue,
                
'link' => $node->getElementsByTagName('link')->item(0)->nodeValue
            
                
//needs to have date converted to fit with db standard
                //this is fine for now for testing only, needs translations
                //'date' => $node->getElementsByTagName('dc:date')->item(0)->nodeValue
            
);
            
array_push($arrFeeds$itemRSS);

            
//now loop through and cleanse the array
            //could this be done once to the whole array?
            //good question buddy..
            
$title $itemRSS['title'];
            
$myFilter = new InputFilter();
            
$title $myFilter->process($title);
            
$title addslashes($title);
        
            
$desc $itemRSS['desc'];
            
$desc substr($desc08000);
            
$myFilter = new InputFilter();
            
$desc $myFilter->process($desc);
            
$desc addslashes($desc);
        
            
$link $itemRSS['link'];
            
$myFilter = new InputFilter();
            
$link $myFilter->process($link);
            
$link addslashes($link);
        
/*
            //check if one of same title already exists
            $sql8 = "SELECT * FROM papers WHERE titulo = '$title' LIMIT 1";
            $query8 = mysql_query($sql8);
            $rows = mysql_num_rows($query8);
        
            if($rows != "1") {//if it's not already in there
            
                //insert to papers table
                //idpapers    tipopaper_idtipopaper    instituciones_idinstituciones    titulo    nombre_publicacion    url    descripcion    resumen    autor    fecha_publicacion    origen    volumen    numero    seccion    pagina_inicio    pagina_fin    identificador_origen
                       
                $sql7 = "INSERT INTO papers (titulo,url,descripcion,testeo) VALUES ('$title','$desc','$link','1')";
            
        //        for testing
                echo $title;
                echo "<br>";
                echo $desc;
                echo "<br>";
                echo $link;
                echo "<br>";
                //echo $date;
                echo "<hr>";
            
                mysql_query($sql7);
        
            }*/
           //        for testing
                
echo $title;
                echo 
"<br>";
                echo 
$desc;
                echo 
"<br>";
                echo 
$link;
                echo 
"<br>";
                
//echo $date;
                
echo "<hr>";
        }
    }
?>