Created
November 14, 2012 12:05
-
-
Save arslnb/4071764 to your computer and use it in GitHub Desktop.
Fetching site data via PHP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body> | |
<?php | |
function getFeed($feed_url) { | |
$content = file_get_contents($feed_url); | |
$x = new SimpleXmlElement($content); | |
echo "<ul>"; | |
foreach($x->channel->item as $entry) { | |
echo " | |
<li> | |
<a href='$entry->link' title='$entry->title'>" . $entry->title . "</a> | |
</li> | |
<li>".$entry->description."</li>"; | |
} | |
echo "</ul>"; | |
} | |
?> | |
/*Enter the RSS feed URL of your target site*/ | |
<?php getFeed("http://rss.example.com/something.xml"); ?> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can read both RSS and ATOM with something like this (not tested).