Reading RSS Feeds
Posted: Wed Nov 30, 2011 1:53 am
After follow the part 2 Tutorial on this I keep getting the following error
I have followed the code exactly.
My code is
If anyone can help in any way I would be very greatful.
Thanks
.Fatal error: Call to a member function attributes() on a non-object in E:\College 2011\USBWebserver v8_en\root\RSS FEED\core\inc\bbc_news_reader.inc.php on line 16]
I have followed the code exactly.
My code is
<?php function fetch_news(){ $data = file_get_contents("http://feeds.bbci.co.uk/news/rss.xml"); $data = simplexml_load_string($data); $articles = array(); foreach($data->channel->item as $item){ $media = $item->children('http://search.yahoo.com/mrss/'); $image = array(); foreach ($media->thumbnail[0]->attributes() as $key => $value){ $image[$key] = (string)$value; } $articles[] = array( 'title' => (string)$item ->title, 'description' =>(string)$item->description, 'link' =>(string)$item->link, 'date' =>(string)$item->pubDate, 'image' =>$image, ); } print_r($articles); } ?>
If anyone can help in any way I would be very greatful.
Thanks