我試圖請求有關域的信息,但沒有成功;代碼:Google SafeBrowsing Lookup API - PHP
<?php
echo file_get_contents('https://sb-ssl.google.com/safebrowsing/api/lookup?client=asasd&apikey=MYKEY&appver=1.5.2&pver=3.0&url=http%3A%2F%2Fwww.onet.pl%2F');
?>
爲什麼不能正常工作?
我試圖請求有關域的信息,但沒有成功;代碼:Google SafeBrowsing Lookup API - PHP
<?php
echo file_get_contents('https://sb-ssl.google.com/safebrowsing/api/lookup?client=asasd&apikey=MYKEY&appver=1.5.2&pver=3.0&url=http%3A%2F%2Fwww.onet.pl%2F');
?>
爲什麼不能正常工作?
只是來看看documentation:
$returned_content = get_data('your url');
get_file_contents()有巨大的安全威脅:從URL獲取數據
function get_data($url)
{
$ch = curl_init();
$timeout = 5;
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
然後通過函數調用獲取內容
//功能在PHP中禁用此功能。
他問的是api訪問,這是正確的安全url。我有與file_get_contents相同的問題,使用curl解決@bitanalyzer說。 – jipipayo