PHP code example of mrzard / open-exchange-rates-service
1. Go to this page and download the library: Download mrzard/open-exchange-rates-service library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mrzard / open-exchange-rates-service example snippets
php
use Mrzard\OpenExchangeRates\Service\OpenExchangeRatesService;
use GuzzleHttp\Client;
...
$apiOptions = array(
'https' => false,
'base_currency' => 'USD'
);
new OpenExchangeRatesService(
$openExchangeRatesApiId, // your id from openExchangeRatesApi
$apiOptions,
new Client()
);
...
php
/**
* Get the latest exchange rates
*
* @param array $symbols Currency codes to get the rates for. Default all
* @param string $base Base currency, default NULL (gets it from config)
*
* @return array
*/
public function getLatest($symbols = array, $base = null)
{
}
php
/**
* Gets a list of all available currencies
*
* @return array with keys = ISO codes, content = Currency Name
*/
public function getCurrencies()
{
}
php
/**
* Get historical data
*
* @param \DateTime $date
* @param array $symbols array of currency codes to get the rates for.
* Default empty (all currencies)
* @param string $base Base currency, default NULL (gets it from config)
*
*/
public function getHistorical(\DateTime $date)
{
}