<?php
include_once('../settings.php');
?>

<?php 
function curl_file_get_contents($url)
{
   $ch = curl_init(); //initiate curl
       curl_setopt($ch, CURLOPT_HEADER, 0);//0 means response headers will not be included in output.
   curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //1 means curl will return the contents as output of this function, instead of printing them inside this function.
   curl_setopt($ch, CURLOPT_URL, $url);
    $data = curl_exec($ch);//request sent to the url
   curl_close($ch);
    return $data;
}
$curl_response = curl_file_get_contents('http://api.wunderground.com/api/'.$api.'/forecast10day/q/pws:'.$id.'.json'); //Just change URL to what ever page you want to fetch
$json = curl_file_get_contents('http://api.wunderground.com/api/'.$api.'/forecast10day/q/pws:'.$id.'.json');
$data = json_encode($json);
$file = '../jsondata/forecast10day.json';
file_put_contents($file, $json);
?>
