• 0
  • 3 RepliesReplies
  • 3143 ReadTimes Read
  • 0 PointsPoints

Topic: Un bloque con lector RSS

Usuario: Lambo
Rango: Excelente User
Mensajes: 94
Points: 64
Mi web: http://foro.breackerz.com
Perfil: View Profile
Pais:
mx
Un bloque con lector RSS
November 29, 2012 - 07:45 19:45
Hola que tal amigos de SMFSimple, bueno queria poner un lector de feeds en mi foro con feeds provenientes de mi blog, y pues me puse a buscar un rato y encontre unos lectores en php, y bien despues me puse a ver como crear un bloque para el portal, ya hice varios experimentos y no me queda el codigo por alguna razon...  Al entrar a la configuracion de bloques me sale este mensaje... "Fatal error: Class 'Block' not found in /home/breacker/public_html/foro/Sources/ssp/FeedBlock.php on line 3"
Les dejo los dos codigos para que me ayuden a colocarlo bien dentro del codigo del bloque...

Codigos de lector
Primer Codigo de lector...
Code: [Select]
<?php 
//$RSS = new LectorRSS ("http://www.tublogenwordpress.com/blog/feed/rss/"; 
$RSS = new LectorRSS ("http://www.taringa.net/rss/ultimos-post/"
class 
LectorRSS 
var 
$url
var 
$data
function 
LectorRSS ($url){ 
$this->url
$this->data implode (""file ($url)); 

function 
obtener_items (){ 
preg_match_all ("/<item .*>.*<\/item>/xsmUi"$this->data$matches); 
$items = array (); 
foreach (
$matches[0] as $match){ 
$items[] = new RssItem ($match); 

return 
$items


class 
RssItem 
var 
$title$url
function 
RssItem ($xml){ 
$this->populate ($xml); 

function 
populate ($xml){ 
preg_match ("/<title> (.*) <\/title>/xsmUi"$xml$matches); 
$this->title $matches[1]; 
preg_match ("/<link> (.*) <\/link>/xsmUi"$xml$matches); 
$this->url $matches[1]; 

function 
obtener_titulo (){ 
return 
$this->title

function 
obtener_url (){ 
return 
$this->url


foreach (
$RSS->obtener_items () as $item){ 
printf ('<a target="_BLANK" href="%s">%s</a><br />'
$item->obtener_url (), $item->obtener_titulo ()); 

?>







Segundo codigo de lector...
Code: [Select]
<?php 
  $long_descripcion
=400;  
$num_noticias=4;  
$n=0;  
$noticias simplexml_load_file('http://urldetuweb.sadas/rss.xml');  
foreach (
$noticias as $noticia) {   
    foreach(
$noticia as $reg){  
        if(
$reg->title!=NULL && $reg->title!='' && $reg->description!=NULL && $reg->description!='' && $n<$num_noticias){  
            echo 
'<b><a href="'.$reg->link.'" target="_blank">'.$reg->title.'</a></b><br>';  
            if(
strlen($reg->description)>$long_descripcion)  
                echo 
'<p>'.substr($reg->description,0,$long_descripcion).'...</a></p><br>';  
            else  
                echo 
'<p>'.$reg->description.'</p><br>';  
            echo 
'Publicado: '.$reg->pubDate.'<br><br>';  
            
$n++;  
        }  
    }  
}   
?>

Y asi es como plantee el codigo...
Code: [Select]
<?

class FeedBlock extends Block{
   
    const SYSKEY = 'FeedBlock';
   
    function __construct()
    {
    }

    public function show()
    {   

  $long_descripcion=400; 
$num_noticias=4; 
$n=0; 
$noticias = simplexml_load_file('http://www.breackerz.com//feeds/posts/default'); 
foreach ($noticias as $noticia) {   
    foreach($noticia as $reg){ 
        if($reg->title!=NULL && $reg->title!='' && $reg->description!=NULL && $reg->description!='' && $n<$num_noticias){ 
            echo '<b><a href="'.$reg->link.'" target="_blank">'.$reg->title.'</a></b><br>'; 
            if(strlen($reg->description)>$long_descripcion) 
                echo '<p>'.substr($reg->description,0,$long_descripcion).'...</a></p><br>'; 
            else 
                echo '<p>'.$reg->description.'</p><br>'; 
            echo 'Publicado: '.$reg->pubDate.'<br><br>'; 
            $n++; 
        } 
    } 
}

Espero su ayuda! Saludos!
Breackerz! | Encuentra lo que buscas!
Website: http://foro.breackerz.com
Usuario: Lean
Rango: Fundador
Mensajes: 6782
Points: 236
Perfil: View Profile
Pais:
ar
Re: Un bloque con lector RSS
Reply #1 November 29, 2012 - 08:48 20:48
Yo estoy sin Internet desde mi pc ya hacer un mes y creo que seguire un mes más así que disculpas por no poder ayudar pero seguramente 4kStore te dará una mano. Es muy interesante lo que queres hacer y yo tenía pensado hacer algo así, obviamente más genérico pero esta bueno!! Seguí intentando, desde el celu no puedo hacer mucho pero si encuentro algo en el código te aviso.

Saludos

Enviado desde mi Galaxy S3 usando tapatalk 2.
Usuario: Lambo
Rango: Excelente User
Mensajes: 94
Points: 64
Mi web: http://foro.breackerz.com
Perfil: View Profile
Pais:
mx
Re:Un bloque con lector RSS
Reply #2 December 06, 2012 - 10:23 22:23
Al final no ha pasado por aqui 4kStore  :'(
Usuario: Lean
Rango: Fundador
Mensajes: 6782
Points: 236
Perfil: View Profile
Pais:
ar
Re:Un bloque con lector RSS
Reply #3 December 30, 2012 - 08:21 08:21
Ya tengo pc asi que seguramente en estos dias retomare accion!
 

TAGS



top

Smfsimple.com es un sitio destinado a brindar un servicio de soporte y herramientas para foros realizados con el sistema de foros gratuito simplemachines.org. Contamos con un selecto equipo de desarrolladores y conocedores del sistema, sus foros estaran en buenas manos.
This site is not affiliated with or endorsed by Simple Machines