Google安全浏览API:无法下载列表

时间:2015-05-08 04:42:46

标签: javascript php curl google-api malware-detection

我正在使用Google安全浏览API V3来检查访问的网址是否安全。但它总是返回0.

以下是我的代码:

function googleDownloader($url)
    {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $headr[] = 'Content-length: 10000';
    curl_setopt($ch, CURLOPT_HTTPHEADER,$headr);
    $body = 'googpub-phish-shavar; goog-malware-shavar; goog-unwanted-shavar;';
    $buildopts = array(CURLOPT_POST=>true,CURLOPT_POSTFIELDS=>$body."\n");
    if(is_array($buildopts))
        curl_setopt_array($ch, $buildopts);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT ,1); 
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_TIMEOUT, 1000);
    $data = curl_exec($ch);
    $info = curl_getinfo($ch);
    if ($data === false)
    {
        // throw new Exception('Curl error: ' . curl_error($crl));
        print_r('Curl error: ' . curl_error($ch));
    }
    //echo $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);        
    return array($info,$data);      
    }

    $url = "https://safebrowsing.google.com/safebrowsing/downloads?client=api&key=mygoogleapikey&appver=1.5.2&pver=3.0";
    $result =  googleDownloader($url);

我想让它产生一个我可以编码并存储在我的数据库中的列表。

我过去两天试过但没有成功。请帮我解决这个问题。

0 个答案:

没有答案