本文整理汇总了PHP中SimplePie::set_curl_options方法的典型用法代码示例。如果您正苦于以下问题:PHP SimplePie::set_curl_options方法的具体用法?PHP SimplePie::set_curl_options怎么用?PHP SimplePie::set_curl_options使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimplePie
的用法示例。
在下文中一共展示了SimplePie::set_curl_options方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getRSSFeed
/**
* Get a specific RSS feed
*
* @param $url string/array URL of the feed or array of URL
* @param $cache_duration timestamp cache duration (default DAY_TIMESTAMP)
*
* @return feed object
**/
static function getRSSFeed($url, $cache_duration = DAY_TIMESTAMP)
{
global $CFG_GLPI;
$feed = new SimplePie();
$feed->set_cache_location(GLPI_RSS_DIR);
$feed->set_cache_duration($cache_duration);
// proxy support
if (!empty($CFG_GLPI["proxy_name"])) {
$prx_opt = array();
$prx_opt[CURLOPT_PROXY] = $CFG_GLPI["proxy_name"];
$prx_opt[CURLOPT_PROXYPORT] = $CFG_GLPI["proxy_port"];
if (!empty($CFG_GLPI["proxy_user"])) {
$prx_opt[CURLOPT_HTTPAUTH] = CURLAUTH_ANYSAFE;
$prx_opt[CURLOPT_PROXYUSERPWD] = $CFG_GLPI["proxy_user"] . ":" . Toolbox::decrypt($CFG_GLPI["proxy_passwd"], GLPIKEY);
}
$feed->set_curl_options($prx_opt);
}
$feed->enable_cache(true);
$feed->set_feed_url($url);
$feed->force_feed(true);
// Initialize the whole SimplePie object. Read the feed, process it, parse it, cache it, and
// all that other good stuff. The feed's information will not be available to SimplePie before
// this is called.
$feed->init();
// We'll make sure that the right content type and character encoding gets set automatically.
// This function will grab the proper character encoding, as well as set the content type to text/html.
$feed->handle_content_type();
if ($feed->error()) {
return false;
}
return $feed;
}
示例2: customSimplePie
function customSimplePie()
{
$system_conf = Minz_Configuration::get('system');
$limits = $system_conf->limits;
$simplePie = new SimplePie();
$simplePie->set_useragent(_t('gen.freshrss') . '/' . FRESHRSS_VERSION . ' (' . PHP_OS . '; ' . FRESHRSS_WEBSITE . ') ' . SIMPLEPIE_NAME . '/' . SIMPLEPIE_VERSION);
$simplePie->set_syslog($system_conf->simplepie_syslog_enabled);
$simplePie->set_cache_location(CACHE_PATH);
$simplePie->set_cache_duration($limits['cache_duration']);
$simplePie->set_timeout($limits['timeout']);
$simplePie->set_curl_options($system_conf->curl_options);
$simplePie->strip_htmltags(array('base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'link', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'plaintext', 'script', 'style'));
$simplePie->strip_attributes(array_merge($simplePie->strip_attributes, array('autoplay', 'onload', 'onunload', 'onclick', 'ondblclick', 'onmousedown', 'onmouseup', 'onmouseover', 'onmousemove', 'onmouseout', 'onfocus', 'onblur', 'onkeypress', 'onkeydown', 'onkeyup', 'onselect', 'onchange', 'seamless')));
$simplePie->add_attributes(array('img' => array('lazyload' => '', 'postpone' => ''), 'audio' => array('lazyload' => '', 'postpone' => '', 'preload' => 'none'), 'iframe' => array('lazyload' => '', 'postpone' => '', 'sandbox' => 'allow-scripts allow-same-origin'), 'video' => array('lazyload' => '', 'postpone' => '', 'preload' => 'none')));
$simplePie->set_url_replacements(array('a' => 'href', 'area' => 'href', 'audio' => 'src', 'blockquote' => 'cite', 'del' => 'cite', 'form' => 'action', 'iframe' => 'src', 'img' => array('longdesc', 'src'), 'input' => 'src', 'ins' => 'cite', 'q' => 'cite', 'source' => 'src', 'track' => 'src', 'video' => array('poster', 'src')));
return $simplePie;
}