SimplePie::force_feed PHP Method

force_feed() public method

This tells SimplePie to ignore the content-type provided by the server. Be careful when using this option, as it will also disable autodiscovery.
Since: 1.1
public force_feed ( boolean $enable = false )
$enable boolean Force the given data/URL to be treated as a feed
    public function force_feed($enable = false)
    {
        $this->force_feed = (bool) $enable;
    }

Usage Example

Ejemplo n.º 1
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;
	}
All Usage Examples Of SimplePie::force_feed