Page 1 of 1

Show an RSS feed on another page including photos

Posted: Thu May 19, 2011 10:02 am
by cnl83
If you goto http://www.actionfx.net/bfd/photos.php you will see that im trying to show an rss feed from http://picasaweb.google.com/data/feed/b ... ess=public

My code works well if its just text on the rss but it does not work on this particular rss. I want the photos to show up on my page also. Im hoping someone here can be so kind to help me out with this coding. Below is my code.

Code: Select all

<?php  
 
$feed_url = "http://picasaweb.google.com/data/feed/base/user/114565750484201639035?alt=rss&kind=album&hl=en_US&access=public";

// INITIATE CURL. 
$curl = curl_init(); 

// CURL SETTINGS. 
curl_setopt($curl, CURLOPT_URL,"$feed_url"); 
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 0); 

// GRAB THE XML FILE. 
$xmlTwitter = curl_exec($curl); 

curl_close($curl); 

// SET UP XML OBJECT.
// Use either one of these, depending on revision of PHP.
// Comment-out the line you are not using.
//$xml = new SimpleXMLElement($xmlTwitter);
$xml = simplexml_load_string($xmlTwitter); 

// How many items to display 
$count = 10; 

// How many characters from each item 
// 0 (zero) will show them all. 
$char = 100; 

foreach ($xml->channel->item as $item) { 
if($char == 0){ 
$newstring = $item->description; 
} 
else{ 
$newstring = substr($item->description, 0, $char); 
} 
if($count > 0){ 
//in case they have non-closed italics or bold, etc ... 
echo"</i></b></u></a>\n"; 
echo" 
<div style='font-family:verdana; font-size:.12;'>  
<b>{$item->title}</b><br />
$newstring ...  <span class='redlink' id='redlink' style='redlink'> <a href='{$item->guid}'>read more</a> </span>
<br /><br /> 
</div> 
";  
} 
$count--; 
}  
?> 

Re: Show an RSS feed on another page including photos

Posted: Thu May 19, 2011 12:05 pm
by Kastor

Code: Select all

foreach ($xml->channel->item as $item) { 
    $description = str_replace(array('/>', '<br/><br/>'), array('/><br/>', '<br />'), strip_tags($item->description, '<img><br/>')); 
    echo '<div>';
    echo '<h3>'.$item->title.'</h3>';
    echo $description.'<br />';
    echo "<span class='redlink' id='redlink' style='redlink'> <a href='{$item->guid}'>read more</a>";
    echo '</div>';
}

Re: Show an RSS feed on another page including photos

Posted: Thu May 19, 2011 12:30 pm
by cnl83
That worked great! I just can't get my read more link to work properly. On the rss feed page the link says "view album". If I could get that to work normally, that would be awesome. How do I call the link thats on the feed?

Re: Show an RSS feed on another page including photos

Posted: Thu May 19, 2011 7:39 pm
by cnl83
Help?

Re: Show an RSS feed on another page including photos

Posted: Fri May 20, 2011 12:02 am
by Kastor

Code: Select all

foreach ($xml->channel->item as $item) { 
    $description = str_replace(array('/>', '<br/><br/>'), array('/><br/>', '<br />'), strip_tags($item->description, '<img><br/><a>')); 
    echo '<div>';
    echo '<h3>'.$item->title.'</h3>';
    echo $description.'<br />';
    echo '</div>';
}