Utils/WikiTagUtils.php
changeset 76 bb7808e180c3
parent 68 e7384fb35f7a
child 77 021131fbe2c5
equal deleted inserted replaced
73:12fc4e8b6fde 76:bb7808e180c3
   198         $url = WikiTagUtils::$WIKIPEDIA_API_URL.'?'.$params_str;
   198         $url = WikiTagUtils::$WIKIPEDIA_API_URL.'?'.$params_str;
   199         
   199         
   200         $ch = curl_init();
   200         $ch = curl_init();
   201         curl_setopt($ch, CURLOPT_URL, $url);
   201         curl_setopt($ch, CURLOPT_URL, $url);
   202         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
   202         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
   203         //TODO: change
   203         // default values
   204         curl_setopt($ch, CURLOPT_USERAGENT, 'http://www.iri.centrepompidou.fr');
   204         curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:10.0.1) Gecko/20100101 Firefox/10.0.1');
   205         curl_setopt($ch, CURLOPT_TIMEOUT_MS, 5000);
   205         curl_setopt($ch, CURLOPT_TIMEOUT_MS, 5000);
       
   206         // Set options if they are set in the config.yml file, typically for proxy configuration.
       
   207         // Thanks to the configuration file, it will execute commands like "curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);" or "curl_setopt($ch, CURLOPT_PROXY, "xxx.yyy.zzz:PORT");"
       
   208         $curl_options = $GLOBALS["kernel"]->getContainer()->getParameter("wiki_tag.curl_options");
       
   209         foreach ($curl_options as $key => $value) {
       
   210             if(strtoupper($value)=='TRUE'){
       
   211                 $value = TRUE;
       
   212             }
       
   213             else if (strtoupper($value)=='FALSE'){
       
   214                 $value = FALSE;
       
   215             }
       
   216             else if (defined($value)){
       
   217                 $value = constant($value);
       
   218             }
       
   219             curl_setopt($ch, constant($key), $value);
       
   220         }
       
   221         // end of treatment
   206         $res = curl_exec($ch);
   222         $res = curl_exec($ch);
   207         $curl_errno = curl_errno($ch);
   223         $curl_errno = curl_errno($ch);
   208         $curl_error = curl_error($ch);
   224         $curl_error = curl_error($ch);
   209         curl_close($ch);
   225         curl_close($ch);
   210         
   226