<?php

//载入全局配置和函数包
require("../../../../include/global.php");

//////////////////////////////////

$callback = getgpc('callback');

$imgbase = 'http://www.google.com';

$api = "http://www.google.com/ig/api?hl=zh_CN&weather=wuhan";
$content = file_get_contents($api);
//$content = iconv('UTF-8', 'GB2312',$content);
$xml = simplexml_load_string($content);
$contents = $xml->weather->current_conditions;
$icon = $xml->weather->current_conditions->icon;
$icon = (array)$icon;
$temp_c = $contents->temp_c;
$temp_c = (array)$temp_c;
$conditiongoo = $contents->condition;
$conditiongoo = (array)$conditiongoo;
$humidity = $contents->humidity;
$humidity = (array)$humidity ;
$wind_condition = $contents->wind_condition;
$wind_condition = (array)$wind_condition;

echo $callback.'({"icon":"'.$imgbase.$icon['@attributes']['data'].'","temp_c":"'.$temp_c['@attributes']['data'].'","condition":"'.$conditiongoo['@attributes']['data'].'","humidity":"'.$humidity['@attributes']['data'].'","wind_condition":"'.$wind_condition['@attributes']['data'].'"});';

/*
//天气图片
echo ("icon".$icon['@attributes']['data']);

//天气最高温度
echo("temp_c".$temp_c['@attributes']['data']);

//天气说明
echo("conditiongoo".$conditiongoo['@attributes']['data']);

//湿度
echo("humidity".$humidity['@attributes']['data']);

//风向
echo("wind_condition".$wind_condition['@attributes']['data']);

//天气地区名
echo('city_name'.$city_name); 
*/
?>