我正在使用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); …Run Code Online (Sandbox Code Playgroud)