Select Page
Basic Weather Widget

Basic Weather Widget

Update: Dark Sky APi was shutdown in August 1st 2020

This is a PHP website that connects to Dark sky API to get current weather conditions and a 5-day weather forecast and display it as a responsive web page. it uses the IP address sent to the web server as a request which is then sent to Ip loc API which sent back the latitude and longitude(20-30 km accuracy) of the Requester.

The libraries and API used in this project were:

Link to Github repo

<?php array(337.5, 22.5),
'NE' => array(22.5, 67.5),
'E' => array(67.5, 112.5),
'SE' => array(112.5, 157.5),
'S' => array(157.5, 202.5),
'SW' => array(202.5, 247.5),
'W' => array(247.5, 292.5),
'NW' => array(292.5, 337.5)
);
// for statement to convert degree to wind direction eg west
foreach ($cardinalDirections as $dir => $angles) { // convert degrees into wind direction => is separator, key value pair
if ($bearing >= $angles[0] && $bearing < $angles[1]) {
// if bearing greater than/equal and less than ,
// then set direction to = dir
$direction = $dir;
break;
}
}
return $direction;
}
$direction = degreeToString($bearing); // calls the degree to string function
//Daily Forecast
$dailySummary = $resultsDark['daily']['summary'];
$dailyIcon = $resultsDark['daily']['icon'];
$dailyCond = array();
foreach ($resultsDark['daily']['data'] as $d) { // for loop through array to find Key daily and value data,
// set that as a new array dailycond
$dailyCond[] = $d;
}
foreach ($dailyCond as $cond) {
$wTempHigh = round($cond['temperatureMax']);
$wTempLow = round($cond['temperatureMin']);
$wTime = $cond['time'];
$wIcon = $cond['icon'];

}
Android Weather App using Darksky API

Android Weather App using Darksky API

Weather forecast data from a free API provided by Darksky.net. The android app then parses the data (in JSON format) and display it in a single-page app. it also can handle errors and situations when the network is unavailable.

Features used in this project are:

  1. Networking
  2. OkHttp
  3. DarkSky API
  4. Parsing JSON feed
  5. DialogFragment