-1
我無法從谷歌API檢索數據。當我運行代碼時,它只返回一個空白頁面,而不是xml數組的打印輸出。下面是代碼:PHP谷歌天氣API查詢
$url="http://www.google.com/ig/api";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, "?weather=london,england");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$data = curl_exec($ch);
curl_close($ch);
echo "<pre>";
print_r($data);
不是XML數組,只是普通的字符串。您需要額外的東西來將這些字符串解析爲XML – ajreal
**谷歌天氣API在2012年被關閉** - > http://stackoverflow.com/questions/12145820/google-weather-api-gone/35943521 –