set_feed_url() public method

This allows you to enter the URL of the feed you want to parse, or the website you want to try to use auto-discovery on. This takes priority over any set raw data. You can set multiple feeds to mash together by passing an array instead of a string for the $url. Remember that with each additional feed comes additional processing and resources.
See also: set_raw_data()
Since: 1.0 Preview Release
public set_feed_url ( string | array $url )
$url string | array This is the URL (or array of URLs) that you want to parse.
Esempio n. 1
0
 /**
  * Display a wildcard in the back end
  *
  * @return string
  */
 public function generate()
 {
     if (TL_MODE == 'BE') {
         /** @var \BackendTemplate|object $objTemplate */
         $objTemplate = new \BackendTemplate('be_wildcard');
         $objTemplate->wildcard = '### ' . utf8_strtoupper($GLOBALS['TL_LANG']['FMD']['rss_reader'][0]) . ' ###';
         $objTemplate->title = $this->headline;
         $objTemplate->id = $this->id;
         $objTemplate->link = $this->name;
         $objTemplate->href = '' . $GLOBALS['TL_CONFIG']['backendPath'] . '/main.php?do=themes&table=tl_module&act=edit&id=' . $this->id;
         return $objTemplate->parse();
     }
     $this->objFeed = new \SimplePie();
     $arrUrls = trimsplit('[\\n\\t ]', trim($this->rss_feed));
     if (count($arrUrls) > 1) {
         $this->objFeed->set_feed_url($arrUrls);
     } else {
         $this->objFeed->set_feed_url($arrUrls[0]);
     }
     $this->objFeed->set_output_encoding(\Config::get('characterSet'));
     $this->objFeed->set_cache_location(TL_ROOT . '/system/tmp');
     $this->objFeed->enable_cache(false);
     if ($this->rss_cache > 0) {
         $this->objFeed->enable_cache(true);
         $this->objFeed->set_cache_duration($this->rss_cache);
     }
     if (!$this->objFeed->init()) {
         $this->log('Error importing RSS feed "' . $this->rss_feed . '"', __METHOD__, TL_ERROR);
         return '';
     }
     $this->objFeed->handle_content_type();
     return parent::generate();
 }
Esempio n. 2
0
	public function update() {
		$feed = new SimplePie();
		$feed->set_feed_url('https://github.com/' . $this->user . '.atom');
		$feed->enable_cache(false);
		$feed->set_stupidly_fast(true);
		$feed->init();

		foreach ($feed->get_items() as $item) {
			$id = $item->get_id();
			$title = substr($item->get_title(), strlen($this->user) + 1);
			$title = sprintf('<a href="%s">%s</a>', $item->get_permalink(), $title);
			$data = array(
				'id' => $id,
				'title' => $title,
				'content' => $item->get_content(),
				'source' => 'github',
				'timestamp' => $item->get_date('U')
			);

			/*$type = substr($id, 20, strpos($id, '/'));
			switch ($type) {
				case 'PushEvent':
				case 'IssueCommentEvent':
				case 'PullRequestEvent':
				case 'IssuesEvent':
				default:
					// no-op, standard stuff will work fine
					break;
			}*/
			Murray_Entry::create($data);
		}

	}
Esempio n. 3
0
 public function respond()
 {
     $url = trim($this->matches[1]);
     $index = 0;
     if (isset($this->matches[2])) {
         $index = intval(trim($this->matches[2]));
         $index = $index - 1;
         $index = max(0, $index);
     }
     $error_level = error_reporting();
     error_reporting($error_level ^ E_USER_NOTICE);
     $feed = new \SimplePie();
     if ($this->cacheEnabled()) {
         $feed->set_cache_location($this->config['cache_directory']);
         $feed->set_cache_duration(600);
     }
     $feed->set_feed_url($url);
     $feed->init();
     $feed->handle_content_type();
     if ($index > $feed->get_item_quantity() - 1) {
         $index = $feed->get_item_quantity() - 1;
     }
     $item = $feed->get_item($index);
     $result = null;
     if ($item) {
         $title = html_entity_decode($item->get_title());
         $link = $item->get_permalink();
         $date = $item->get_date();
         $i = $index + 1;
         $result = "[{$i}] {$date} - {$title} - {$link}";
     }
     error_reporting($error_level);
     return $result;
 }
 function fetch_feed2($url)
 {
     require_once ABSPATH . WPINC . '/class-feed.php';
     $feed = new SimplePie();
     $feed->set_sanitize_class('WP_SimplePie_Sanitize_KSES');
     // We must manually overwrite $feed->sanitize because SimplePie's
     // constructor sets it before we have a chance to set the sanitization class
     $feed->sanitize = new WP_SimplePie_Sanitize_KSES();
     $feed->set_cache_class('WP_Feed_Cache');
     $feed->set_file_class('WP_SimplePie_File');
     $feed->set_feed_url($url);
     $feed->force_feed(true);
     /** This filter is documented in wp-includes/class-feed.php */
     $feed->set_cache_duration(apply_filters('wp_feed_cache_transient_lifetime', 12 * HOUR_IN_SECONDS, $url));
     /**
      * Fires just before processing the SimplePie feed object.
      *
      * @since 3.0.0
      *
      * @param object &$feed SimplePie feed object, passed by reference.
      * @param mixed  $url   URL of feed to retrieve. If an array of URLs, the feeds are merged.
      */
     do_action_ref_array('wp_feed_options', array(&$feed, $url));
     $feed->init();
     $feed->handle_content_type();
     if ($feed->error()) {
         return new WP_Error('simplepie-error', $feed->error());
     }
     return $feed;
 }
Esempio n. 5
0
	public function update() {
		$feed = new SimplePie();
		$feed->set_feed_url('http://api.twitter.com/1/statuses/user_timeline.atom?screen_name=' . $this->user);
		$feed->enable_cache(false);
		$feed->set_stupidly_fast(true);
		$feed->init();

		foreach ($feed->get_items() as $item) {
			$title = substr($item->get_title(), strlen($this->user) + 2);
			$title = sprintf('<blockquote>%s</blockquote>', $title);
			$data = array(
				'id' => $item->get_id(),
				'title' => Twitter_Autolink::create($title)
					->setTarget(false)
					->setExternal(false)
					->addLinks(),
				'content' => '',
				'source' => 'twitter',
				'timestamp' => $item->get_date('U')
			);

			Murray_Entry::create($data);
		}


	}
Esempio n. 6
0
 function showBlogLastArticles()
 {
     $content = '';
     $feed = new SimplePie();
     $feed->set_feed_url(array('http://bilboplanet.com/feed/'));
     $feed->set_cache_duration(600);
     #	$feed->enable_xml_dump(isset($_GET['xmldump']) ? true : false);
     $success = $feed->init();
     $feed->handle_content_type();
     if ($success) {
         $content .= '<div class="box-dashboard"><div class="top-box-dashboard">' . T_('BilboPlanet news - Official Website :') . '</div>';
         $content .= '<ul>';
         $itemlimit = 0;
         foreach ($feed->get_items() as $item) {
             if ($itemlimit == 4) {
                 break;
             }
             $content .= '<li>' . $item->get_date('j/m/y') . ' : ';
             $content .= '<a class="tips" rel="' . $item->get_title() . '" href="' . $item->get_permalink() . '" target="_blank">' . $item->get_title() . '</a>';
             $content .= '</li>';
             $itemlimit = $itemlimit + 1;
         }
         $content .= '</ul></div>';
     }
     return $content;
 }
Esempio n. 7
0
 public static function simplepie($feed_url = NULL)
 {
     if (!$feed_url) {
         return false;
     }
     $data = new SimplePie();
     //*******************************
     // Convert To GeoRSS feed
     // To Disable Uncomment these 3 lines
     //*******************************
     $geocoder = new Geocoder();
     $georss_feed = $geocoder->geocode_feed($feed_url);
     if ($georss_feed == false or empty($georss_feed)) {
         // Our RSS feed pull failed, so let's grab the original RSS feed
         $data->set_feed_url($feed_url);
     } else {
         // Converting our feed to GeoRSS was successful, use that data
         $data->set_raw_data($georss_feed);
     }
     // Uncomment Below to disable geocoding
     //$data->set_feed_url( $feed_url );
     //*******************************
     $data->enable_cache(false);
     $data->enable_order_by_date(true);
     $data->init();
     $data->handle_content_type();
     return $data;
 }
Esempio n. 8
0
function flickr_photos($feed_url, $max_items = 10)
{
    //$items = combine_feeds( array($feed_url), $max_items, '~', false);
    $feed = new SimplePie();
    $feed->set_feed_url($feed_url);
    $feed->set_cache_location(ABSPATH . '/cache');
    $feed->set_output_encoding('ISO-8859-1');
    $feed->init();
    $html = '';
    if ($feed->data) {
        foreach ($feed->get_items(0, $max_items) as $item) {
            $image = $item->get_description();
            $image = substr($image, strpos($image, 'src=') + 4);
            // '<img') + 10);
            $image = trim(substr($image, 0, strpos($image, '.jpg') + 4));
            // , "\" width")));
            $healthy = array("%3A", "%2F", '"', 'm.jpg');
            $yummy = array(":", "/", '', 's.jpg');
            $image = str_replace($healthy, $yummy, $image);
            //$image = str_replace('m.jpg', 's.jpg', $image);
            $html .= '<a href="' . $item->get_permalink() . '">';
            $html .= '<img src="' . $image . '" alt="[flickr photo: ' . $item->get_title() . ']" title="' . $item->get_title() . '" />';
            $html .= "</a>\n";
        }
    }
    return $html;
}
 public function import($forceResync)
 {
     if (get_option('goodreads_user_id')) {
         if (!class_exists('SimplePie')) {
             require_once ABSPATH . WPINC . '/class-feed.php';
         }
         $rss_source = sprintf(self::$apiurl, get_option('goodreads_user_id'));
         /* Create the SimplePie object */
         $feed = new SimplePie();
         /* Set the URL of the feed you're retrieving */
         $feed->set_feed_url($rss_source);
         /* Tell SimplePie to cache the feed using WordPress' cache class */
         $feed->set_cache_class('WP_Feed_Cache');
         /* Tell SimplePie to use the WordPress class for retrieving feed files */
         $feed->set_file_class('WP_SimplePie_File');
         /* Tell SimplePie how long to cache the feed data in the WordPress database */
         $feed->set_cache_duration(apply_filters('wp_feed_cache_transient_lifetime', get_option('reclaim_update_interval'), $rss_source));
         /* Run any other functions or filters that WordPress normally runs on feeds */
         do_action_ref_array('wp_feed_options', array(&$feed, $rss_source));
         /* Initiate the SimplePie instance */
         $feed->init();
         /* Tell SimplePie to send the feed MIME headers */
         $feed->handle_content_type();
         if ($feed->error()) {
             parent::log(sprintf(__('no %s data', 'reclaim'), $this->shortname));
             parent::log($feed->error());
         } else {
             $data = self::map_data($feed);
             parent::insert_posts($data);
             update_option('reclaim_' . $this->shortname . '_last_update', current_time('timestamp'));
         }
     } else {
         parent::log(sprintf(__('%s user data missing. No import was done', 'reclaim'), $this->shortname));
     }
 }
Esempio n. 10
0
 public function addSystemMessages()
 {
     if ($GLOBALS['TL_CONFIG']['be_rss_src'] == '') {
         return '';
     }
     $feed = new \SimplePie();
     $feed->set_feed_url(html_entity_decode($GLOBALS['TL_CONFIG']['be_rss_src']));
     $feed->set_output_encoding(\Config::get('characterSet'));
     $feed->set_cache_location(TL_ROOT . '/system/tmp');
     $feed->enable_cache(true);
     if (!$feed->init()) {
         $this->log('Error importing RSS feed "' . $this->rss_feed . '"', __METHOD__, TL_ERROR);
         return '';
     }
     $items = $feed->get_items(0, $GLOBALS['TL_CONFIG']['be_rss_max'] ? $GLOBALS['TL_CONFIG']['be_rss_max'] : 3);
     $output = '';
     if ($items) {
         $user = \BackendUser::getInstance();
         foreach ($items as $item) {
             $template = new \BackendTemplate('be_rss_item');
             $template->title = $item->get_title();
             $template->link = $item->get_link();
             $template->content = $item->get_content();
             $template->date = $item->get_date($GLOBALS['TL_CONFIG']['datimFormat']);
             $template->class = $item->get_date('U') > $user->lastLogin ? 'new' : 'message';
             $output .= $template->parse();
         }
     }
     $template = new \BackendTemplate('be_rss');
     $template->headline = $GLOBALS['TL_CONFIG']['be_rss_headline'];
     $template->items = $output;
     return $template->parse();
 }
Esempio n. 11
0
 /**
  * _createSimplePie
  *
  * @param   string  &$feed  Params
  *
  * @return	object
  */
 private function _createSimplePie(&$feed)
 {
     include_once JPATH_AUTOTWEET . '/libs/SimplePie_autoloader.php';
     // Process the feed with SimplePie
     $simplePie = new SimplePie();
     $simplePie->set_feed_url($feed->xtform->get('url'));
     $simplePie->set_stupidly_fast(true);
     $simplePie->enable_order_by_date(true);
     if ($feed->xtform->get('encoding', 'utf-8')) {
         $simplePie->set_input_encoding($feed->xtform->get('encoding'));
     }
     if ($feed->xtform->get('force_fsockopen')) {
         $simplePie->force_fsockopen(true);
     }
     $use_sp_cache = EParameter::getComponentParam(CAUTOTWEETNG, 'use_sp_cache', true);
     if ($use_sp_cache && is_writable(JPATH_CACHE)) {
         $simplePie->set_cache_location(JPATH_CACHE);
         $simplePie->enable_cache(true);
     } else {
         $simplePie->enable_cache(false);
     }
     $set_sp_timeout = EParameter::getComponentParam(CAUTOTWEETNG, 'set_sp_timeout', 10);
     if ($set_sp_timeout) {
         $simplePie->set_timeout((int) $set_sp_timeout);
     }
     $simplePie->init();
     return $simplePie;
 }
Esempio n. 12
0
	/**
	 * Get a parsed XML Feed Source
	 *
	 * @param   string   $url         Url for feed source.
	 * @param   integer  $cache_time  Time to cache feed for (using internal cache mechanism).
	 *
	 * @return  mixed  SimplePie parsed object on success, false on failure.
	 *
	 * @since   12.2
	 * @deprecated  4.0   Use JFeedFactory($url) instead.
	 *
	 * @note  In 3.2 will be proxied to JFeedFactory()
	 */
	public static function getFeedParser($url, $cache_time = 0)
	{
		JLog::add(__METHOD__ . ' is deprecated.   Use JFeedFactory() or supply Simple Pie instead.', JLog::WARNING, 'deprecated');

		$cache = JFactory::getCache('feed_parser', 'callback');

		if ($cache_time > 0)
		{
			$cache->setLifeTime($cache_time);
		}

		$simplepie = new SimplePie(null, null, 0);

		$simplepie->enable_cache(false);
		$simplepie->set_feed_url($url);
		$simplepie->force_feed(true);

		$contents = $cache->get(array($simplepie, 'init'), null, false, false);

		if ($contents)
		{
			return $simplepie;
		}

		JLog::add(JText::_('JLIB_UTIL_ERROR_LOADING_FEED_DATA'), JLog::WARNING, 'jerror');

		return false;
	}
Esempio n. 13
0
 /**
  * Fetches and parses an RSS or Atom feed, and returns its items.
  *
  * Each element in the returned array will have the following keys:
  *
  * - **authors** – An array of the item’s authors, where each sub-element has the following keys:
  *     - **name** – The author’s name
  *     - **url** – The author’s URL
  *     - **email** – The author’s email
  * - **categories** – An array of the item’s categories, where each sub-element has the following keys:
  *     - **term** – The category’s term
  *     - **scheme** – The category’s scheme
  *     - **label** – The category’s label
  * - **content** – The item’s main content.
  * - **contributors** – An array of the item’s contributors, where each sub-element has the following keys:
  *     - **name** – The contributor’s name
  *     - **url** – The contributor’s URL
  *     - **email** – The contributor’s email
  * - **date** – A {@link DateTime} object representing the item’s date.
  * - **dateUpdated** – A {@link DateTime} object representing the item’s last updated date.
  * - **permalink** – The item’s URL.
  * - **summary** – The item’s summary content.
  * - **title** – The item’s title.
  *
  * @param string $url           The feed’s URL.
  * @param int    $limit         The maximum number of items to return. Default is 0 (no limit).
  * @param int    $offset        The number of items to skip. Defaults to 0.
  * @param string $cacheDuration Any valid [PHP time format](http://www.php.net/manual/en/datetime.formats.time.php).
  *
  * @return array|string The list of feed items.
  */
 public function getFeedItems($url, $limit = 0, $offset = 0, $cacheDuration = null)
 {
     $items = array();
     if (!extension_loaded('dom')) {
         Craft::log('Craft needs the PHP DOM extension (http://www.php.net/manual/en/book.dom.php) enabled to parse feeds.', LogLevel::Warning);
         return $items;
     }
     if (!$cacheDuration) {
         $cacheDuration = craft()->config->getCacheDuration();
     } else {
         $cacheDuration = DateTimeHelper::timeFormatToSeconds($cacheDuration);
     }
     $feed = new \SimplePie();
     $feed->set_feed_url($url);
     $feed->set_cache_location(craft()->path->getCachePath());
     $feed->set_cache_duration($cacheDuration);
     $feed->init();
     // Something went wrong.
     if ($feed->error()) {
         Craft:
         log('There was a problem parsing the feed: ' . $feed->error(), LogLevel::Warning);
         return array();
     }
     foreach ($feed->get_items($offset, $limit) as $item) {
         $date = $item->get_date('U');
         $dateUpdated = $item->get_updated_date('U');
         $items[] = array('authors' => $this->_getItemAuthors($item->get_authors()), 'categories' => $this->_getItemCategories($item->get_categories()), 'content' => $item->get_content(true), 'contributors' => $this->_getItemAuthors($item->get_contributors()), 'date' => $date ? new DateTime('@' . $date) : null, 'dateUpdated' => $dateUpdated ? new DateTime('@' . $dateUpdated) : null, 'permalink' => $item->get_permalink(), 'summary' => $item->get_description(true), 'title' => $item->get_title(), 'enclosures' => $this->_getEnclosures($item->get_enclosures()));
     }
     return $items;
 }
Esempio n. 14
0
 function add($render)
 {
     $url = $_REQUEST['url'];
     require_once 'lib/simplepie/simplepie.inc';
     $pie = new SimplePie();
     $pie->enable_cache(false);
     $pie->set_autodiscovery_level(SIMPLEPIE_LOCATOR_ALL);
     $pie->set_feed_url($url);
     $pie->init();
     $feed_url = $pie->feed_url;
     $feed_title = $pie->get_title();
     // Save feed to insert into session variables for later insertion into db
     // only do this if we found items at the given url. This way we won't
     // insert broken urls in doadd(). Also prevents inserting a new feed
     // that never gets subscribed to in the following page.
     if (count($pie->get_items()) > 0) {
         $_SESSION['new_feed_url'] = $feed_url;
         $_SESSION['new_feed_name'] = $feed_title;
     } else {
         $_SESSION['new_feed_url'] = NULL;
         $_SESSION['new_feed_name'] = NULL;
     }
     $render->assign('url', $url);
     $render->assign('feed_url', $feed_url);
     $render->assign('items', array_slice($pie->get_items(), 0, 5));
     $render->assign('feed', $pie);
     $render->assign('title', 'Adding Feed');
     $render->display('feed_search.tpl');
 }
 /**
  * Loads a newsfeed object.
  * @param string $feed
  * @return SimplePie $feed
  */
 public function load($feedurl)
 {
     $feed = new SimplePie();
     $feed->set_feed_url($feedurl);
     $feed->set_cache_location(DIR_FILES_CACHE);
     return $feed;
 }
Esempio n. 16
0
 public function html()
 {
     // Get settings
     $settings = $this->config;
     // Define Simplepie
     $feed = new \SimplePie();
     $feed->set_feed_url($settings['feed']);
     $feed->enable_cache($settings['enable_cache']);
     $feed->set_cache_location(cache_path());
     $feed->set_cache_duration(60 * 60 * 12);
     $feed->set_output_encoding($settings['charset']);
     $feed->init();
     $title = $settings['title'];
     $data = [];
     foreach ($feed->get_items($settings['offset'], $settings['limit']) as $key => $item) {
         $data[$key]['title'] = $item->get_title();
         $data[$key]['permalink'] = $item->get_permalink();
         $data[$key]['date'] = $item->get_date();
         $data[$key]['updated_date'] = $item->get_updated_date();
         $data[$key]['author'] = $item->get_author();
         $data[$key]['category'] = $item->get_category();
         $data[$key]['description'] = $item->get_description();
         $data[$key]['content'] = $item->get_content();
     }
     return $this->view('rssfeed', compact('title', 'data'));
 }
Esempio n. 17
0
 /**
  * see http://simplepie.org/wiki/reference/start#simplepie_item
  *
  * @return array SimplePie_Item
  */
 static function getFeed($url)
 {
     $feed = new SimplePie();
     $feed->set_feed_url($url);
     $feed->enable_cache(false);
     $feed->init();
     return $feed;
 }
Esempio n. 18
0
 /**
  * RSS news page
  *
  * @param Request $request
  * @param Application $app
  */
 public function newsRss(Request $request, Application $app)
 {
     $simplePie = new \SimplePie();
     $simplePie->set_feed_url($app['resources']['news_rss']);
     $simplePie->init();
     $items = $simplePie->get_items();
     return $app['twig']->render('main/news-rss.twig', ['items' => $items]);
 }
Esempio n. 19
0
 public function __construct($url)
 {
     $simplePie = new \SimplePie();
     $simplePie->set_cache_location(getcwd() . '/cache');
     $simplePie->set_feed_url($url);
     $simplePie->init();
     $simplePie->handle_content_type();
     $this->rawData = $simplePie;
 }
Esempio n. 20
0
 public function __construct($url)
 {
     $simplePie = new \SimplePie();
     $simplePie->set_cache_location($_SERVER['DOCUMENT_ROOT'] . '/zowcast/rest/cache');
     $simplePie->set_feed_url($url);
     $simplePie->init();
     $simplePie->handle_content_type();
     $this->rawData = $simplePie;
 }
Esempio n. 21
0
 private function get_feed($feed_url)
 {
     $feed = new SimplePie();
     $feed->set_feed_url($feed_url);
     $feed->enable_order_by_date(true);
     $feed->set_item_limit(3);
     $feed->init();
     $feed->handle_content_type();
     return $feed;
 }
 private function loadFromWebService()
 {
     $feed = new \SimplePie();
     $feed->set_feed_url($this->endPoint);
     $feed->set_cache_location(THELIA_ROOT . 'cache/feeds');
     $feed->init();
     $feed->handle_content_type();
     $feed->set_timeout(10);
     $this->data = $feed->get_items();
 }
Esempio n. 23
0
 public function getNews()
 {
     $feed = new SimplePie();
     $feed->set_feed_url('http://feeds.rapidfeeds.com/54082/');
     $success = $feed->init();
     if (!$success) {
         throw new Exception('couldnt init blog feed');
     }
     return $feed->get_items();
 }
Esempio n. 24
0
 function fetchRss($url)
 {
     $feed = new SimplePie();
     $feed->set_feed_url($url);
     $feed->set_output_encoding("UTF-8");
     $feed->enable_order_by_date(false);
     $feed->set_cache_location(Configure::read('Rss.cache_path'));
     $feed->init();
     return $feed->get_items();
 }
Esempio n. 25
0
 public function __construct(array $feedUrls)
 {
     require_once __DIR__ . '/../autoloader.php';
     $feed = new \SimplePie();
     $feed->set_cache_location(__DIR__ . '/cache');
     $feed->set_feed_url($feedUrls);
     $feed->init();
     $feed->handle_content_type();
     $this->feed = $feed;
 }
 /**
  * Return an array of consumed Tweets from the RSS feed
  *
  * @access public
  * @return array
  **/
 public function get_news_feed($add_news_to_db = TRUE)
 {
     // Use SimplePie to get the RSS feed
     $feed = new SimplePie();
     $feed->set_feed_url(array($this->search_query));
     $feed->set_item_limit(50);
     $feed->handle_content_type();
     $feed->enable_cache(false);
     $feed->init();
     // Get the feed and create the SimplePie feed object
     $this->feed = $feed->get_items();
     $post = array();
     // Array to hold all the tweet info for returning as an array
     $retval = array();
     // Set up two counters (1 for use in the return array and 1 for counting the number of inserted posts if applicable)
     $n = 0;
     $i = 0;
     // Array to hold the stored hashtags
     $hashes = explode(',', $this->options["hashtags"]);
     foreach ($feed->get_items() as $item) {
         // Get the Twitter status id from the status href
         $twitter_status_id = explode("/", $item->get_id());
         // Check to see if the username is in the user profile meta data
         $post["user_id"] = (int) $this->options["user"];
         $user_id = $this->map_twitter_to_user($twitter_status_id[3]);
         if (!$user_id == NULL) {
             $post["user_id"] = (int) $user_id;
         }
         // Add individual Tweet data to array
         $post["date"] = date("Y-m-d H:i:", strtotime($item->get_date()));
         $post["link"] = $item->get_id();
         $post["id"] = $twitter_status_id[count($twitter_status_id) - 1];
         $post["description"] = $item->get_description();
         $post["description_filtered"] = $this->strip_hashes($item->get_description(), $hashes);
         $post["twitter_username"] = $twitter_status_id[3];
         $post["twitter_username_link"] = $this->create_twitter_link($twitter_status_id[3]);
         $post["post_type"] = "twitter";
         // Add the new post to the db?
         if ($add_news_to_db) {
             if ($this->add_item_as_post($post)) {
                 $i++;
             }
         }
         // Add the Tweet to the return array
         $retval[$n] = $post;
         $n++;
     }
     // Return correct values depending on the $add_news_to_db boolean
     if ($add_news_to_db) {
         return $i;
     } else {
         return $retval;
     }
 }
Esempio n. 27
0
function rss($url)
{
    $feed = new SimplePie();
    $feed->set_feed_url($url);
    $feed->handle_content_type();
    // Display content:
    echo '<h2>' . $feed->get_title() . '<br />';
    foreach ($feed->get_items() as $item) {
        echo $item->get_title();
    }
}
 protected function fetch_rss()
 {
     include_once ABSPATH . WPINC . '/class-simplepie.php';
     $feed = new SimplePie();
     $feed->set_feed_url($this->feed_url);
     $feed->enable_cache(true);
     $feed->set_cache_location($this->cache_directory);
     $feed->set_cache_duration($this->cache_duration);
     $feed->init();
     $this->feed = $feed;
     return $this;
 }
Esempio n. 29
0
 static function add($url)
 {
     require_once 'lib/simplepie_1.3.compiled.php';
     $feed = new SimplePie();
     $feed->set_feed_url($_POST['url']);
     $feed->enable_cache(false);
     $feed->init();
     $feed->handle_content_type();
     $values = array(':id' => $feed->feed_url, ':site' => $feed->get_link(), ':title' => $feed->get_title());
     $result = Feeds::$db->exec("INSERT OR IGNORE INTO feeds " . "(id, site_url, title) VALUES (:id, :site, :title)", $values);
     return $result == 0 ? FALSE : TRUE;
 }
Esempio n. 30
0
 /**
  * fetchFeed method
  *
  * @return void
  */
 public function fetchFeed($url = false)
 {
     if (!is_string($url)) {
         return false;
     }
     $feed = new SimplePie();
     $feed->set_cache_location(CACHE);
     $feed->set_feed_url($url);
     $feed->init();
     $feed->handle_content_type();
     return $feed;
 }