Advertisement
Guest User

Untitled

a guest
Mar 21st, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. $city = isset($_GET['city']) ? $_GET['city'] : $currentCity ;
  2. $url = 'http://api.openweathermap.org/data/2.5/forecast?q='.$city.'&appid=a12942698b2839d023a8bf84f4066b06&units=metric';
  3. $path = './cache/'.md5($url);
  4.  
  5. if(file_exists($path) && time() - filemtime($path) < 60)
  6. {
  7. $data = file_get_contents($path);
  8. $data = json_decode($data);
  9. }
  10. else{
  11. $data = file_get_contents($url);
  12. $data = json_decode($data);
  13. file_put_contents($path, json_encode($data));
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement