adentone Posted September 17, 2010 Share Posted September 17, 2010 I am creating this feature for a client of mine that needs it working by tomorrow! I am trying to use cURL to grab the RSS feed here: http://blogs.menshealth.com/fitness-pros/feed But all I get back is an empty string... Please help - I've been searching Google & this forum but haven't found anything that I can use that fixes this issue. $feed = getRssData(); echo "<pre>\n"; print_r( $feed ); echo "\n</pre>\n"; function getRssData() { // returns the feed array $requested_feed = "http://blogs.menshealth.com/fitness-pros/feed"; $ch = curl_init($requested_feed); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0); $rss_data = curl_exec($ch); curl_close($ch); echo "RSS DATA: <br />\n" . $rss_data; $doc = new DOMDocument(); $doc->load($rss_data); $arrFeeds = array(); foreach ($doc->getElementsByTagName('item') as $node) { $itemRSS = array ( 'title' => $node->getElementsByTagName('title')->item(0)->nodeValue, 'desc' => $node->getElementsByTagName('description')->item(0)->nodeValue, 'link' => $node->getElementsByTagName('link')->item(0)->nodeValue, 'date' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue ); array_push($arrFeeds, $itemRSS); } return $arrFeeds; } You can see a live test here: http://pro-formpt.com/get_rss.php?feed=workout It only has a few parameters in it so I can use the same file to grab other RSS Feeds as well - but they all fail the same way. Like this one: http://pro-formpt.com/get_rss.php?feed=living Which should grab the feed from here: http://blogs.menshealth.com/mh-life/feed I truly appreciate any suggestions! Thanks! Link to comment https://forums.phpfreaks.com/topic/213624-urgent-using-curl-to-get-rss-feed-fails-think-i-am-really-close-help/ Share on other sites More sharing options...
adentone Posted September 17, 2010 Author Share Posted September 17, 2010 Do I need to set some special headers or something? I really need help on this ASAP. Thank you!!! Link to comment https://forums.phpfreaks.com/topic/213624-urgent-using-curl-to-get-rss-feed-fails-think-i-am-really-close-help/#findComment-1112159 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.