I'm just starting to play around with SimplePie, and have created a basic test page that will display the results of an RSS feed on a webpage. This works well when testing a handful of pages, but fails silently when trying to view an Apple Forum feed.
Any suggestions on how to troubleshoot this issue?
<?php
require_once('php/autoloader.php');
$feed = new SimplePie();
$feed->set_feed_url(
'https://discussions.apple.com//community/feeds/search?q=mathtype&peopleEnabled=true&dateRange=all&rankBy=date'
);
$feed->force_feed(true);
$feed->init();
$feed->handle_content_type();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN">
<html>
<head>
<title>Sample SimplePie Page</title>
</head>
<body>
<div class="header">
<h1><a href="<?php echo $feed->get_permalink(); ?>"><?php echo $feed->get_title(); ?></a></h1>
<p><?php echo $feed->get_description(); ?></p>
</div>
<?php
foreach ($feed->get_items() as $item):
?>
<div class="item">
<h2><a href="<?php echo $item->get_permalink(); ?>"><?php echo $item->get_title(); ?></a></h2>
<p><?php echo $item->get_description(); ?></p>
<p><small>Posted on <?php echo $item->get_date('j F Y | g:i a'); ?></small></p>
</div>
<?php endforeach; ?>
</body>
</html>
You're going to kick yourself... I checked the return value of $feed->init()
and it was false
, so I took out the extra / before "community" in your url and it seems to work.
https://discussions.apple.com/community/feeds/search?q=mathtype&peopleEnabled=true&dateRange=all&rankBy=date
When you use the double / in your browser, it ignores it, but SimplePie does not.