require_once('./conf/config.php'); require_once('./models/exchanges.php'); $exchanges=new exchanges(); $days = array(); for($i = 1; $i < 10; $i++) { $days[] = date("Y-m-d", strtotime('-'. $i .' days')); } foreach ($days as $day) { $json = file_get_contents('http://openexchangerates.org/api/historical/'.$day.'.json?app_id=YOURAPIID'); $data = json_decode($json, TRUE); $conversion=$data['rates']['EUR']; if ($exchanges->exists($day)) { $ret=$exchanges->update($day, $conversion); } else { $ret=$exchanges->insert($day, $conversion); } echo($day.' '.$conversion.' '.$ret).SEP; }
Enjoy!!!