Skip to content

Instantly share code, notes, and snippets.

@robv
Created September 1, 2009 07:09
Show Gist options
  • Save robv/178956 to your computer and use it in GitHub Desktop.
Save robv/178956 to your computer and use it in GitHub Desktop.
Sample RSS Usage
<?pnp
// TODO: Implement cache system
public function rss()
{
$feed = new Rss;
$feed->title = 'Konnect';
$api_check = new Users;
if ($api_check->verify_api_token(Router::uri(4)))
{
if (Router::uri(3) === 'announcements')
{
$feed->title .= ' - Latest Announcements';
$this->data['announcements'] = new Admin_Announcements;
$query = 'SELECT admin_announcements.*, users.username FROM admin_announcements LEFT JOIN users ON admin_announcements.author = users.id LIMIT 0,10';
$this->data['announcements'] = $this->data['announcements']->select_many($query, array('username'));
foreach ($this->data['announcements'] as $announcement)
{
$item = new Rss_Item();
$item->title = $announcement->title;
$item->link = WEB_ROOT . Router::uri(0) . '/view/admin_announcements/' . $announcement->id . '/';
$item->description = $announcement->comments;
$item->set_pub_date(String::format_date($announcement->date_posted, 'F j, g:i a'));
$feed->add_item($item);
}
}
$feed->serve();
}
else
{
die('You are not authorized for this feed, please check that your api token is correct');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment