2017-12-12 3 views
0

I 암호로 보호 된 https url에서 xml 파일을 받으려면 다음 함수를 사용하십시오. 난 더 이상 XML 파일을받을 couldnt는 그 이후 7.0.22PHP 업데이트 후 CURL URL에서 XML 가져 오는 작업이 중지되었습니다.

: 우리의 서버 버전에 PHP 업데이트를 가지고 때까지

function get_fcontent($url, $javascript_loop = 0, $timeout = 5) { 

    $url = str_replace("&", "&", urldecode(trim($url))); 
    $cookie = tempnam ("/tmp", "CURLCOOKIE"); 
    $ch = curl_init(); 

    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3) Gecko/20041001 Firefox/0.10.1"); 
    curl_setopt($ch, CURLOPT_URL, $url); 
    curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie); 
    curl_setopt($ch, CURLOPT_ENCODING, ""); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
    curl_setopt($ch, CURLOPT_AUTOREFERER, true); 
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); # required for https urls 
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); 
    curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); 
    curl_setopt($ch, CURLOPT_MAXREDIRS, 10); 
    $content = curl_exec($ch); 
    $response = curl_getinfo($ch); 
    curl_close ($ch); 

    if ($response['http_code'] == 301 || $response['http_code'] == 302) { 
     ini_set("user_agent", "Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3) Gecko/20041001 Firefox/0.10.1"); 

     if ($headers = get_headers($response['url'])) { 
      foreach($headers as $value) { 
       if (substr(strtolower($value), 0, 9) == "location:") 
        return get_url(trim(substr($value, 9, strlen($value)))); 
      } 
     } 
    } 

    if ( (preg_match("/>[[:space:]]+window\.location\.replace\('(.*)'\)/i", $content, $value) || preg_match("/>[[:space:]]+window\.location\=\"(.*)\"/i", $content, $value)) && $javascript_loop < 5) { 
     return get_url($value[1], $javascript_loop+1); 
    } else { 
     return array($content, $response); 
    } 
} 

모든했다. 나는 빈 응답을 얻는다. 누군가가 그 이유를 알고 있습니까?

편집 : 이전에 어떤 PHP 버전이 설치되었는지는 모르지만 다운 그레이드 할 수 없습니다.

+0

서버의 오류 로그를 확인하십시오. 연결된 오류가 있습니까? –

+0

내 변수 (내부의 xml 데이터 포함)가 비어 있다는 경고 만 표시 – Remling

+0

그래, 디버깅 시작 : 코드의 어느 부분이 여전히 작동합니까? –

답변

관련 문제