Created
December 7, 2009 07:15
-
-
Save rmccue/250682 to your computer and use it in GitHub Desktop.
Normalise SimplePie items to put into a database
This file contains 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
<?php | |
require('simplepie.inc'); | |
$feed = new SimplePie('http://example.com/feed/'); | |
foreach($feed->get_items() as $item) { | |
$new_item = (object) array( | |
'hash' => $item->get_id(true), | |
'timestamp' => $item->get_date('U'), | |
'title' => $item->get_title(), | |
'content' => $item->get_content(), | |
'summary' => $item->get_description(), | |
'permalink' => $item->get_permalink(), | |
'metadata' => (object) array( | |
'enclosure' => $enclosure | |
), | |
'author' => (object) $author, | |
'feed' => $item->get_feed()->get_link() | |
); | |
$items[] = $new_item; | |
} | |
// Save item array to database, where $database is some sort of DB interface | |
$database->save_items($items); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment