Visualizzazione dei risultati da 1 a 3 su 3
  1. #1

    come creare un rss feed

    Ciao ragazzi, volevo creare un piccolo rss feed per una pagina html che segnala soltando sei link.. questa pagina non viene aggiornata spesso... quindi mi servirebbe un rss statico che magari poi apro e vado a d aggiungere io il nuovo oggetto...

    qualcuno mi può aiutare indicandomu qualche guida alla creazione di un rss feed?

    me ne servirebbe anche uno per il mio forum...

  2. #2
    Moderatore di Server Apache L'avatar di marketto
    Registrato dal
    Sep 2001
    Messaggi
    5,858
    think simple think ringo

  3. #3
    Non capisco una cosa... utiliizzo questo codice che è presente sulla guida in questo sito.
    codice:
    <?php
    class MakeRSS{
      var $Articles = array();
    
      // Channel info
      var $title = '';
      var $link = '';
      var $description = '';
      var $optional = array();
      var $image = array('url' => '', 'title' => '', 'link' => '', 'description' => '', 'w' => 0, 'h' => 0);
    
      function MakeRSS($title, $link, $description, $optional = ''){
        $this->title = $title;
        $this->link = $link;
        $this->description = $description;
    
        if( is_array($optional) and count($optional) ){
          $this->optional = $optional;
        }
      }
      
      function AddOptional($key, $value){
        $this->optional[$key] = $value;
      }
    
      function AddImage($title, $url, $link, $description = ''){
        $this->image['title'] = $title;
        $this->image['url'] = $url;
        $this->image['link'] = $link;
        $this->image['description'] = $description;
    
        if( $tmp = @getimagesize($url) ){
          $this->image['w'] = ($tmp[0] > 144) ? 144 : $tmp[0];
          $this->image['h'] = ($tmp[1] > 400) ? 400 : $tmp[1];
        }
      }
      
      function AddArticle($title, $link, $description, $author, $optional = ''){
        $i = array_push($this->Articles, array('title' => $title, 'link' => $link, 'description' => $description, 'author' => $author));
    
        if( is_array($optional) and count($optional) ){
          --$i;
          while( list($k, $v) = each($optional) ){
             $this->Articles[$i][$k] = $v;
          }
        }
      }
    
      function Output($save = false, $path = ''){
        $out = '<?xml version="1.0"?>' . "\n" . 
           '<rss version="2.0">' . "\n" .
           '<channel>' . "\n";
           
        $out .= "<title>$this->title</title>\n" .
            "<link>$this->link</link>\n" .
            "<description>$this->description</description>\n";
        
        //Channel optionals
        if( is_array($this->optional) and count($this->optional) ){
          while( list($k, $v) = each($this->optional) ){
            $out .= "<$k>$v</$k>\n";
          }
        }
        
    //Image
      if( $this->image['title'] and $this->image['url'] and $this->image['link'] ){
       $out .= "<image>\n" .
         "<title>" . $this->image['title'] . "</title>\n" .
         "<url>" . $this->image['url'] . "</url>\n" .
         "<link>" . $this->image['link'] . "</link>\n";
    
       if( $this->image['description'] ){
        $out .= "<description>" . $this->image['description'] . "</description>\n";
       }
    
       if( $this->image['w'] and $this->image['h'] ){
        $out .= "<width>" . $this->image['w'] . "</width>\n" .
          "<height>" . $this->image['h'] . "</height>\n";
       }
       $out .= "</image>\n";
      }
    
        //Articles
        for( $i = 0, $c = count($this->Articles); $i < $c; $i++ ){
           $out .= "<item>\n" .
               "<title>" . $this->Articles[$i]['title'] . "</title>\n" .
               "<link>" . $this->Articles[$i]['link'] . "</link>\n" .
               "<description>" . $this->Articles[$i]['description'] . "</description>\n" .
               "<author>" . $this->Articles[$i]['author'] . "</author>\n";
    
           if( count($this->Articles[$i]) > 4 ){
             while( list($k, $v) = each($optional) ){
               if( !in_array($k, array('title', 'link', 'description', 'author')) ){
                 $out .= "<$k>$v</$k>\n";
               }
             }
           }
    
    
           $out .= "</item>\n";
        }
    
        $out .= "</channel>\n</rss>";
    
    
        // True output
        if( !$save or !$path ){
          header("Content-type: application/xml");
          echo $out;
          return true;
        }
        else{
          $fh = fopen($path, 'w');
          if( $fh ){
            fwrite($fh, $out);
            fclose($fh);        
            
            return true;
          }
          return false;
        }
      }
    }
    ?>
    Inserisci i campi personalizzati.. ad esempio:

    codice:
    ]<?php
    class MakeRSS{
      var $Articles = array();
    
      // Channel info
      var $title = 'Titolo del sito o del servizio';
      var $link = 'Link del sito o del servizio';
      var $description = 'Descrizione..';

    Dove inserisco la serie di documenti che intendo far visualizzare al rss?

    un ultima cosa questa parte del codice

    codice:
      var $image = array('url' => '', 'title' => '', 'link' => '', 'description' => '', 'w' => 0, 'h' => 0);
    Che significa?

    Grazie ragazzi della pazienza

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.