Skip to content

Instantly share code, notes, and snippets.

@rotten77
Created February 4, 2016 08:42
Show Gist options
  • Save rotten77/14be7867eded71cb33ff to your computer and use it in GitHub Desktop.
Save rotten77/14be7867eded71cb33ff to your computer and use it in GitHub Desktop.
Blogger.com RSS feed reader
<?php
$feed = file_get_contents('http://www.adsr.cz/feeds/posts/default');
$xml = simplexml_load_string($feed);
$items = array();
foreach($xml->entry as $entry) {
$url = null;
foreach($entry->link as $itemLink) {
$attributes = $itemLink->attributes();
if($attributes['rel']=="alternate") $url = (string)$attributes['href'];
}
$items[] = array(
'title' => (string)$entry->title,
'content' => trim(strip_tags((string)$entry->content)),
'published' => date("Y-m-d H:i:s", strtotime($entry->published)),
'url' => $url,
);
}
print_r($items);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment