我正在使用AccuWeather API,并且在JSON formate中获得了如下所示的以下数据,同时我也得到了latitude and longitude
。现在,我想使用latitude and longitude
显示一个天气小部件,正如我在PHP代码中提到的那样,我得到了两者,但是我不知道如何使用它?请帮助我在网络应用上显示天气小部件。
代码:
<?php
$url="http://dataservice.accuweather.com/locations/v1/cities/search?apikey=*****************************&q=ghaziabad";
$contents = file_get_contents($url);
$clima = json_decode($contents);
$latitude = $clima[0]->GeoPosition->Latitude;
$logitude = $clima[0]->GeoPosition->Longitude;
?>
AccuWeather API:
[
{
"Version": 1,
"Key": "206683",
"Type": "City",
"Rank": 25,
"LocalizedName": "Ghaziabad",
"EnglishName": "Ghaziabad",
"PrimaryPostalCode": "",
"Region": {
"ID": "ASI",
"LocalizedName": "Asia",
"EnglishName": "Asia"
},
"Country": {
"ID": "IN",
"LocalizedName": "India",
"EnglishName": "India"
},
"AdministrativeArea": {
"ID": "UP",
"LocalizedName": "Uttar Pradesh",
"EnglishName": "Uttar Pradesh",
"Level": 1,
"LocalizedType": "State",
"EnglishType": "State",
"CountryID": "IN"
},
"TimeZone": {
"Code": "IST",
"Name": "Asia/Kolkata",
"GmtOffset": 5.5,
"IsDaylightSaving": false,
"NextOffsetChange": null
},
"GeoPosition": {
"Latitude": 28.665,
"Longitude": 77.408,
"Elevation": {
"Metric": {
"Value": 200.0,
"Unit": "m",
"UnitType": 5
},
"Imperial": {
"Value": 656.0,
"Unit": "ft",
"UnitType": 0
}
}
},
"IsAlias": false,
"SupplementalAdminAreas": [
{
"Level": 2,
"LocalizedName": "Ghaziabad",
"EnglishName": "Ghaziabad"
},
{
"Level": 3,
"LocalizedName": "Ghaziabad",
"EnglishName": "Ghaziabad"
}
],
"DataSets": [
"AirQuality",
"PremiumAirQuality"
]
}
]
谢谢