leewillis77/open-exchange-rates-api

A PHP wrapper for the 'open exchange rates' API.

v1.0 2014-09-24 06:32 UTC

This package is auto-updated.

Last update: 2024-03-29 03:06:50 UTC


README

A PHP wrapper around the Open Exchange Rates API.

Installation

  • Clone the repository
  • Make sure you have composer set up and working
  • Install dependencies by running composer install
  • Copy the sample config file (config/config.yml.sample) to config/config.yml
  • Update config/config.yml with your API credentials from "open exchange rates"
  • API responses are cached in the cache/ subfolder - disallow access to this in your web server config.

Notes

  • Docblocks are missing in many places - patches welcome
  • PHPUnit is set up, and some test cases are present. More would be welcome.
  • Requires PHP 5.3 or above.

Examples

See the examples folder for a simple example of how to use the API wrapper. This is designed to get you going, and is not a complete reference, or see the code sample below:

use OpenExchangeRates\Config;
use OpenExchangeRates\Request\ConversionRequest;

require('vendor/autoload.php');

$config = new Config('config/config.yml');
$request = new ConversionRequest($config);

try {
    $response = $request->convert(100, 'USD', 'GBP');
} catch (\Exception $e) {
    die('Request exception received: '.$e->getMessage());
}
echo "100 USD is " . $response . " GBP\n";

Disclaimer

This API is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the the developer(s) be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software.

Although every attempt is made to ensure quality, NO guarantees are given whatsoever of accuracy, validity, availability, or fitness for any purpose - please use at your own risk.