<?php
/*
example usage
exchangeRates ver 1.0
You must get an API key from https://exchangeratesapi.io/pricing/
and enter it in the exchangerates.class.php file
For complete documentation on each endpoint and available paramaters
see https://exchangeratesapi.io/documentation/
*/
//turning off low level notices
error_reporting(E_ALL ^ E_NOTICE);
//instantiate the class
require('exchangerates.class.php');
$exchange = new exchangeRates();
//get exhange rate for USD to GBP,JPY,EUR
$exchange->setEndPoint('latest');
$exchange->setParam( 'base', 'USD' );
$exchange->setParam( 'symbols', 'GBP,JPY,EUR' );
//get response from API
$exchange->getResponse();
//dump response object
echo '<strong>Current Rates</strong>';
echo '<pre>';
var_dump($exchange->response);
echo '</pre>';
//get historical rates from Dec 24 2013
$exchange->setEndPoint('historical', '2013-12-24');
//get response from API
$exchange->getResponse();
//dump response object
echo '<strong>Historical Rates</strong>';
echo '<pre>';
var_dump($exchange->response);
echo '</pre>';
die;
?>
|