Created
December 4, 2012 00:46
-
-
Save u10int/4199467 to your computer and use it in GitHub Desktop.
Outputting Aeris Data in HW3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%%CODE __ | |
$response = file_get_contents("http://api.aerisapi.com/observations/closest?p=%%zipcode%%&client_id= CLIENT_ID &client_secret= CLIENT_SECRET "); __ | |
$json = json_decode($response); __ | |
if ($json->success == true) { __ | |
$Country = $json->response[0]->place->country; __ | |
$cond = $json->response[0]->ob; __ | |
echo ("<tr><td width='100%' colspan='2' align='center'><img src='%%hwvImagesPath%%" . ($tIcon=(!empty($cond->icon)) ? $cond->icon : "na.gif") . "' alt='" . $cond->weather . "' width='%%hwvImgWidth%%' height='%%hwvImgHeight%%' /></td></tr>"); __ | |
echo ("<tr><td width='100%' colspan='2' align='center'><span class='Wx'>" . ($tWxshort=(!empty($cond->weatherShort)) ? $cond->weatherShort : "N/A") . "</span></td></tr>"); __ | |
echo ("<tr><td valign='top'><span class='Temp'>Temp:</span></td><td valign='top' align='right'><span class='Temp'>" . ($tTemp=(!empty($cond->tempF)) ? (($Country == 'us') ? $cond->tempF : $cond->tempC) . "°" : "N/A") . "</span></td></tr>"); __ | |
echo ("</table></td><td valign='top' align='center'><table border='0'>"); __ | |
echo ("<tr><td valign='top'><span class='Label'>Humidity:</span></td><td align='right'><span class='Value'>" . ($tHum=(!empty($cond->humidity)) ? $cond->humidity . "%" : "N/A") . "</span></td></tr>"); __ | |
echo ("<tr><td valign='top'><span class='Label'>Wind Speed:</span></td><td align='right'><span class='Value'>" . ($tWindDir=(!empty($cond->windSpeedMPH)) ? $cond->windDir : "Calm") . " " . ($tWindSpd=(!empty($cond->windSpeedMPH)) ? $cond->windSpeedMPH . " MPH" : "") . ($tWindGust=(!empty($cond->windGustMPH)) ? " G" : "") . ($tWindGust=(!empty($cond->windGustMPH)) ? $cond->windGustMPH : "") . "</span></td></tr>"); __ | |
echo ("<tr><td valign='top'><span class='Label'>Barometer:</span></td><td align='right'><span class='Value'>" . ($tPress=(!empty($cond->pressureIN)) ? $cond->pressureIN . " in." : "N/A") . "</span></td></tr>"); __ | |
echo ("<tr><td valign='top'><span class='Label'>Dewpoint:</span></td><td align='right'><span class='Value'>" . ($tDp=(!empty($cond->dewpointF)) ? $cond->dewpointF . "°F" : "N/A") . "</span></td></tr>"); __ | |
echo ("<tr><td valign='top'><span class='Label'>Heat Index:</span></td><td align='right'><span class='Value'>" . ($tHi=(!empty($cond->heatindexF)) ? $cond->heatindexF . "°F" : "N/A"). "</span></td></tr>"); __ | |
echo ("<tr><td valign='top'><span class='Label'>Wind Chill:</span></td><td align='right'><span class='Value'>" . ($tWc=(!empty($cond->windchillF)) ? $cond->windchillF . "°F" : "N/A") . "</span></td></tr>"); __ | |
} __ | |
CODE%% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment