<?php 
	/**
	  * Weather Call for Current Weather of location
	  * Location: Lagos, Nigeria
	  * API Provider: Open Weather
	**/


function get_current_weather(){
	$lat 	= 	'6.6137';
	$lon	=	'3.3553';
	$api	=	'3b9c649202f2d7c24791f5539d6aec35';
	$excl	= 	'minutely,hourly,daily,alerts';

	// $url = "https://api.openweathermap.org/data/3.0/onecall?lat=$lat&lon=$lon&exclude=$excl&appid=$api";
	$url 	=	"https://api.openweathermap.org/data/2.5/weather?lat=$lat&lon=$lon&appid=$api";

	// Initialize cURL session
	$ch = curl_init();

	// Set cURL options
	curl_setopt( $ch, CURLOPT_URL, $url );
	curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); // Return the response as a string instead of outputting it directly

	// Execute the cURL request
	$response = curl_exec( $ch );
	
	if (curl_errno( $ch )) {
		$curl_error = 'cURL error: ' . curl_error($ch);
		return $curl_error;
	} else {	
		// Decode the JSON response
		$response = json_decode( $response, true);
		return $response;
	}
	// Close the cURL session
	curl_close( $ch );
}
?>