-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathweather.php
More file actions
27 lines (25 loc) · 819 Bytes
/
Copy pathweather.php
File metadata and controls
27 lines (25 loc) · 819 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?php
if (!isset($_GET["zip"]) || !isset($_GET["country"]) || !isset($_GET["lat"]) || !isset($_GET["lon"]) || !isset($_GET["ge"])) {
echo "Error: Missing parameters";
exit();
} else {
$apikey = getenv('OPENWEATHER_API_KEY');
$zip = $_GET["zip"];
$country = $_GET["country"];
$lat = $_GET["lat"];
$lon = $_GET["lon"];
$ge = $_GET["ge"];
if ($ge=="false") {
$call = "https://api.openweathermap.org/data/2.5/weather?zip=".$zip.",".$country."&appid=".$apikey;
} else {
$call = "https://api.openweathermap.org/data/2.5/weather?lat=".$lat."&lon=".$lon."&appid=".$apikey;
}
$fp = fopen($call, "r");
$contents = "";
while ($more = fread($fp, 1000)) {
$contents .= $more;
}
echo $contents;
fclose($fp);
}
?>