2014-11-09 2 views
1

페이스 북 그룹 용 크롤러를 구축하려고하는데이 점을 실행할 때 페이지 내용 얻을 : "SSL 인증서 problemq : 지역 발급자 인증서를 얻을 수 없습니다""SSL 인증서 문제 : 로컬 발급자 인증서를 가져올 수 없습니다."

<?php 
    $url = "https://www.facebook.com/groups/theGroupId/"; 

    $ch = curl_init($url);        // initialize the CURL library in my PHP script so we can later work on it - inside the handler. 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);  // curl_setopt() function is used to set options on the $ch handler.// in this case we use the CURLOPT_RETURNTRANSFER option 
    $curl_scraped_page = curl_exec($ch);    // "run all the stuff we've set" - return the data scraped to the variable $curl_scraped_page 

    var_dump($curl_scraped_page); 
    if ($curl_scraped_page === false) { 
     die(curl_error($ch)); 
    } 
    curl_close($ch); 
    echo $curl_scraped_page; 
?> 

을 나는이 오류가 발생합니다. 이것은 정확

<?php 
    $url = "https://www.facebook.com/groups/{theGroupId}/"; 

    $ch = curl_init($url);        // initialize the CURL library in my PHP script so we can later work on it - inside the handler. 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);  // curl_setopt() function is used to set options on the $ch handler.// in this case we use the CURLOPT_RETURNTRANSFER option 
    //curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true); 
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); 
    curl_setopt($ch, CURLOPT_CAINFO, getcwd() . "/CAcerts/GTECyberTrustGlobalRoot.crt"); 


    $curl_scraped_page = curl_exec($ch);    // "run all the stuff we've set" - return the data scraped to the variable $curl_scraped_page 

    var_dump($curl_scraped_page); 
    if ($curl_scraped_page === false) { 
     die(curl_error($ch)); 
    } 


    curl_close($ch); 



    echo $curl_scraped_page; 
?> 

: 왜 이런 일, 2 개 가지 방법으로 그것을 해결하는 방법을 설명 http://unitstep.net/blog/2009/05/05/using-curl-in-php-to-access-https-ssltls-protected-sites/, 나는 모두를 시도했지만 여전히 같은 오류 메시지가 :

나는이 튜토리얼을 건너 실행 출력 (var_dump 포함) :

내가 잘못하고 있나? 이것은 어쨌든 이것을하기위한 올바른 방법입니까?

+0

1. 인증서를 무시하거나 2. 페이스 북 인증서 발급자를 식별 할 수있는 적절한 CA 인증서 파일을 사용하십시오 – DevZer0

답변

1
<?php 

$url = "http://www.facebook.com/groups/4189052132/"; 
function curl($url) { 
    $options = Array(
    CURLOPT_RETURNTRANSFER => TRUE, 
    CURLOPT_FOLLOWLOCATION => TRUE, 
    CURLOPT_AUTOREFERER => TRUE, 
    CURLOPT_CONNECTTIMEOUT => 120, 
    CURLOPT_TIMEOUT => 120, 
    CURLOPT_MAXREDIRS => 10, 
    CURLOPT_USERAGENT => "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1a2pre) Gecko/2008073000 Shredder/3.0a2pre ThunderBrowse/3.2.1.8", 
    CURLOPT_URL => $url, 
    CURLOPT_COOKIE => $session 
); 
    $ch = curl_init(); 
    curl_setopt_array($ch, $options); 
    $data = curl_exec($ch); 
    curl_close($ch);  
    return $data; 
} 
$scraped_page = curl($url); 
echo $scraped_page; 
?> 

인증서를 확인할 필요가 없습니다. 그것이 당신이 문제를 얻는 이유입니다.

관련 문제