コード例 #1
0
ファイル: SolrList.php プロジェクト: emilymwang8/ajk-broker
 public static function get_json_from_lucene($url, $need_debug = true)
 {
     $logfile = APF::get_instance()->get_config("save_curltime_path");
     $curl = curl_init($url);
     curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-type:text/xml; charset=utf-8"));
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 5);
     curl_setopt($curl, CURLOPT_TIMEOUT, 5);
     $start = microtime(true);
     $res = curl_exec($curl);
     $end = microtime(true);
     if (Uri_Curl::enable_save_curl() && $end - $start > 1) {
         $content = "time:" . ($end - $start) . " date:" . date('d H:i:s', time()) . " url:" . $url . "\n";
         Uri_Curl::write_file($logfile, $content);
     }
     $info = curl_getinfo($curl);
     curl_close($curl);
     if ($need_debug) {
         APF::get_instance()->debug($url);
     }
     if ($info['http_code'] != 200) {
         return "[]";
     }
     return $res;
 }