Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $city = isset($_GET['city']) ? $_GET['city'] : $currentCity ;
- $url = 'http://api.openweathermap.org/data/2.5/forecast?q='.$city.'&appid=a12942698b2839d023a8bf84f4066b06&units=metric';
- $path = './cache/'.md5($url);
- if(file_exists($path) && time() - filemtime($path) < 60)
- {
- $data = file_get_contents($path);
- $data = json_decode($data);
- }
- else{
- $data = file_get_contents($url);
- $data = json_decode($data);
- file_put_contents($path, json_encode($data));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement