SimplePie::set_curl_options PHP Method

set_curl_options() public method

This allows you to change default curl options
Since: 1.0 Beta 3
public set_curl_options ( array $curl_options = [] )
$curl_options array Curl options to add to default settings
    public function set_curl_options(array $curl_options = array())
    {
        $this->curl_options = $curl_options;
    }

Usage Example

Example #1
0
 /**
  * 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;
 }
All Usage Examples Of SimplePie::set_curl_options