Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Francisco Mat
committed
May 9, 2018
1 parent
fda2ecc
commit bfb3b04
Showing
1 changed file
with
31 additions
and
10 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,43 @@ | ||
<?php | ||
$city = $_GET['c1-t']; | ||
|
||
if(!isset($city) || $city==NULL) | ||
$city='London,uk'; | ||
?> | ||
|
||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Bravi Weather Simples</title> | ||
<title>Bravi Weather Simple</title> | ||
</head> | ||
<body> | ||
<h1>City Weather</h1> | ||
<p>Check out any city weather. Write city name below:</p> | ||
<form method="GET" name="c1" action="index.php"> | ||
<input type="text" name="c1-t"> | ||
<input type="submit" name="c1-s" value="verify"> | ||
</form> | ||
<?php | ||
$url = 'http://api.openweathermap.org/data/2.5/weather?q=London,uk&appid=808268433b2e03a5e15354526a3e7712'; | ||
$ch = curl_init($url); | ||
#$fp = fopen("pagina_exemplo.txt", "w"); | ||
|
||
#curl_setopt($ch, CURLOPT_FILE, $fp); | ||
#curl_setopt($ch, CURLOPT_HEADER, 0); | ||
$url = 'http://api.openweathermap.org/data/2.5/weather?q='.$city.'&appid=808268433b2e03a5e15354526a3e7712'; | ||
#$ch = curl_init($url); | ||
#$r=curl_exec($ch); | ||
#$j=json_decode($r); | ||
$r = file_get_contents($url); | ||
$j = json_decode($r); | ||
|
||
curl_exec($ch); | ||
curl_close($ch); | ||
#fclose($fp); | ||
echo '<hr />'; | ||
echo 'City: '.$city; | ||
echo '<br />'; | ||
echo 'Current main weather: '.$j->weather[0]->main; | ||
echo '<br />'; | ||
echo 'Description: '.$j->weather[0]->description; | ||
echo '<br />'; | ||
echo 'Temperature: '.$j->main->temp." °F"; | ||
|
||
echo "teste"; | ||
?> | ||
<p>Author: Francisco Matelli Matulovic</p> | ||
<p>Released under GNU GPLv3</p> | ||
|
||
</body> | ||
</html> |