genista Posted March 22, 2014 Share Posted March 22, 2014 All,I have most of the info I want from rss feeds, but I cannot seem to get anything on the image, here is the full code I am testing: <?php libxml_use_internal_errors(true); $RSS_DOC = simpleXML_load_file('http://rss.cnn.com/rss/cnn_topstories.rss'); if (!$RSS_DOC) { //Errors } else{ //setup rss feed } $RSSimagedetails = $RSS_DOC->channel->image; $RSSitem = $RSS_DOC->channel->item[0]; $item_id = md5($RSSitem->title); //$fetch_date = date("Y-m-j G:i:s"); //NOTE: we don't use a DB SQL function so its database independant $item_title = $RSSitem->title; //$item_description = $RSSitem->description; $item_date = date("Y-m-j G:i:s", strtotime($RSSitem->pubDate)); $item_url = $RSSitem->link; //$item_image = $RSSitem->getElementsByTagName('image')->item(0)->getAttribute('url'); $item_image_src = $RSS_DOC->channel->image->src; $item_image_link = $RSS_DOC->channel->image->link; $Pubdate = $RSSitem->pubDate; echo "<p>item_id = $item_id</p>"; echo "<p>item_title =$item_title</p>"; echo "<p>item_url = $item_url</p>"; echo "<p>iem_image_src = $item_image_src</p>"; echo "<p>item_image_link = $item_image_link</p>"; echo "<img src=\"" . (string)$RSSitem->enclosure['url'][0] . "\">"; None of the image items are returning anything, any ideas on the best way to pull this out - specifically the url of the image?Thanks,G Quote Link to comment https://forums.phpfreaks.com/topic/287182-pulling-image-from-rss-feed/ Share on other sites More sharing options...
QuickOldCar Posted March 23, 2014 Share Posted March 23, 2014 You can not get images that don't exist in the feed. http://rss.cnn.com/rss/cnn_topstories.rss Quote Link to comment https://forums.phpfreaks.com/topic/287182-pulling-image-from-rss-feed/#findComment-1473573 Share on other sites More sharing options...
Solution genista Posted March 23, 2014 Author Solution Share Posted March 23, 2014 I guess I need to read through the item in the feed and then retrieve the image, I was hoping to do it this way but never mind. Thanks, g Quote Link to comment https://forums.phpfreaks.com/topic/287182-pulling-image-from-rss-feed/#findComment-1473586 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.