Skip to content

Instantly share code, notes, and snippets.

@jackboberg
Created March 15, 2010 00:40
Show Gist options
  • Save jackboberg/332376 to your computer and use it in GitHub Desktop.
Save jackboberg/332376 to your computer and use it in GitHub Desktop.
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Feed Helper
*
* @package CodeIgniter
* @subpackage Helpers
* @category Helpers
*
* @author Jack Boberg
* @copyright ( coded by hand ) 2010-03
* @license http://creativecommons.org/licenses/BSD/
*/
// ------------------------------------------------------------------------
/**
* get a Simplepie object with feed loaded
*
* @access public
* @param string $url - URL of feed to load
* @return object Simplepie
*/
if ( ! function_exists('get_feed'))
{
function get_feed($url)
{
$CI =& get_instance();
$CI->load->library('simplepie');
$feed = new SimplePie();
$feed->set_cache_location(BASEPATH . 'cache');
$feed->set_feed_url($url);
if ( ! $feed->init()) {
log_message('debug', $feed->error());
return FALSE;
}
$feed->handle_content_type();
return $feed;
}
}
// ------------------------------------------------------------------------
/* End of feed_helper.php */
/* Location: ./applications/helpers/feed_helper.php */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment