1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

how to extract images from a rss feed pleas need help !!!!!!!!!!!!

Discussion in 'XML & RSS' started by theliopro, Jun 22, 2012.

?

je pose bien mes questions ?

Poll closed Jun 26, 2012.
  1. yes

    0 vote(s)
    0.0%
  2. no

    0 vote(s)
    0.0%
Multiple votes are allowed.
  1. #1
    Hi everybody , I'm about to try to display an RSS feed on my web page.
    I can display links to descriptions and titles of RSS but I can not do display images of the links.
    Here is an example of what I want to do : http://dupont-orthez.notaires.fr/
    i use rsslib :
    <?php
    /*
    RSS Extractor and Displayer
    (c) 2007-2009 Scriptol.com - Licence Mozilla 1.1.
    rsslib.php
    
    Requirements:
    - PHP 5.
    - A RSS feed.
    
    Using the library:
    Insert this code into the page that displays the RSS feed:
    
    <?php
    require_once("rsslib.php");
    echo RSS_Display("http://www.xul.fr/rss.xml", 15);
    ?>
    
    */
    $RSS_Content = array();
    
    function RSS_Tags($item, $type)
    {
    $y = array();
    $tnl = $item->getElementsByTagName("title");
    $tnl = $tnl->item(0);
    $title = $tnl->firstChild->textContent;
    
    $tnl = $item->getElementsByTagName("link");
    $tnl = $tnl->item(0);
    $link = $tnl->firstChild->textContent;
    
    $tnl = $item->getElementsByTagName("description");
    $tnl = $tnl->item(0);
    $description = $tnl->firstChild->textContent;
    
    $tnl = $item->getElementsByTagName("image");
    $tnl = $tnl->item(0);
    $image = $tnl->firstChild->data;
    
    $tnl = $item->getElementsByTagName("pubDate");
    $tnl = $tnl->item(0);
    $date = $tnl->firstChild->textContent;
    $date = date("d/m/Y", strtotime("$date"));
    
    $y["title"] = $title;
    $y["link"] = $link;
    $y["description"] = $description;
    $y["image"] = $image;
    $y["date"] = $date;
    $y["type"] = $type;
    
    
    return $y;
    }
    
    
    function RSS_Channel($channel)
    {
    global $RSS_Content;
    
    $items = $channel->getElementsByTagName("item");
    
    // Processing channel
    
    $y = RSS_Tags($channel, 0); // get description of channel, type 0
    array_push($RSS_Content, $y);
    
    // Processing articles
    
    foreach($items as $item)
    {
    $y = RSS_Tags($item, 1); // get description of article, type 1
    array_push($RSS_Content, $y);
    }
    }
    
    function RSS_Retrieve($url)
    {
    global $RSS_Content;
    
    $doc = new DOMDocument();
    $doc->load($url);
    
    $channels = $doc->getElementsByTagName("channel");
    
    $RSS_Content = array();
    
    foreach($channels as $channel)
    {
    RSS_Channel($channel);
    }
    
    }
    
    
    function RSS_RetrieveLinks($url)
    {
    global $RSS_Content;
    
    $doc = new DOMDocument();
    $doc->load($url);
    
    $channels = $doc->getElementsByTagName("channel");
    
    $RSS_Content = array();
    
    foreach($channels as $channel)
    {
    $items = $channel->getElementsByTagName("item");
    foreach($items as $item)
    {
    $y = RSS_Tags($item, 1); // get description of article, type 1
    array_push($RSS_Content, $y);
    }
    
    }
    
    }
    
    
    function RSS_Links($url, $size = 15)
    {
    global $RSS_Content;
    
    $page = "<ul>";
    
    RSS_RetrieveLinks($url);
    if($size > 0)
    $recents = array_slice($RSS_Content, 0, $size + 1);
    
    foreach($recents as $article)
    {
    $type = $article["type"];
    if($type == 0) continue;
    $title = $article["title"];
    $link = $article["link"];
    $page .= "<li><a target=\"_blank\" href=\"$link\">$title</a></li>\n";
    }
    
    $page .="</ul>\n";
    
    return $page;
    
    }
    
    
    
    function RSS_Display($url, $size = 15, $site = 0)
    {
    global $RSS_Content;
    
    $opened = false;
    $page = "";
    $site = (intval($site) == 0) ? 1 : 0;
    
    RSS_Retrieve($url);
    if($size > 0)
    $recents = array_slice($RSS_Content, $site, $size + 1 - $site);
    
    foreach($recents as $article)
    {
    $type = $article["type"];
    if($type == 0)
    {
    if($opened == true)
    {
    $page .="</ul>\n";
    $opened = false;
    }
    $page .="<b>";
    }
    else
    {
    if($opened == false)
    {
    $page .= "<ul>\n";
    $opened = true;
    }
    }
    $title = $article["title"];
    $link = $article["link"];
    $description = $article["description"];
    $image = $article["image"];
    $page .= "<li><a target=\"_blank\" href=\"$link\">$title<img src=\"$image\" /></a>"; /*".$article['date']."*/
    if($description != false)
    {
    $page .= "<br>$description<br>";
    $page .= $article['date'];
    }
    $page .= "</li>\n";
    
    if($type==0)
    {
    $page .="</b><br />";
    }
    
    }
    
    if($opened == true)
    {
    $page .="</ul>\n";
    }
    return $page."\n";
    
    }
    
    ?>
    
    PHP:
    the page wich called rsslib is :

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>page test avec flux rss</title>
    </head>
    
    <body bgcolor="#FFFFFF">
    <h1>RSS 2.0 Direct Démo</h1>
    <hr>
    <div id="zone" > Charger directement un flux RSS et afficher la liste des articles récents.</div>
    
    <br>
    <fieldset class="rsslib">
    <?php
    require_once("rsslib.php");
    $url = "http://www.notaires.fr/notaires/plugins/rss/Actualites.xml";
    echo RSS_Display($url, 15, false, true);
    ?>
    </fieldset>
    </body>
    </html>
    PHP:
    NEED HELP THANK YOU !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     
    theliopro, Jun 22, 2012 IP