benmajor / exchangeratesapi Goto Github PK
View Code? Open in Web Editor NEWAn unofficial SDK for the ExchangeRatesAPI.
Home Page: https://exchangeratesapi.io/
License: MIT License
An unofficial SDK for the ExchangeRatesAPI.
Home Page: https://exchangeratesapi.io/
License: MIT License
Apparently, "the awesome, free ExchangeRatesAPI" is no longer that free. As of today, our services relying upon this API started to fail, and I discovered that exchangeratesapi.io started to require API key, and only 250 requests/month are free. Everyone needs to run their server.
Just had an issue here, i think its related to the Endpoint Response?
How to produce the error
$lookup = new ExchangeRatesAPI();
$rates = $lookup->addRate('USD')->setBaseCurrency('SGD')->fetch();
$rate = $rates->getRates();
echo $rate;
Libraries Used
"guzzlehttp/guzzle": "^6.4"
"benmajor/exchange-rates-api": "^1.0"
"php": "^7.1.3"
I noticed in the list
private $_currencies = [ 'USD', 'GBP', 'EUR', 'JPY', 'BGN', 'CZK', 'DKK', 'HUF', 'PLN', 'RON', 'SEK', 'CHF', 'ISK', 'NOK', 'HRK', 'RUB', 'TRY', 'AUD', 'BRL', 'CAD', 'CNY', 'HKD', 'IDR', 'ILS', 'INR', 'KRW', 'MXN', 'MYR', 'NZD', 'BHP', 'SGD', 'THB', 'ZAR' ];
There are BHP currencies but no PHP
So is there a mistake here?
The library lists 33 supported currencies, but the service now supports 168 currencies now.
Hi,
I am trying to call some functions (E.g. trying to get the base currency below) from the ones available in ExchangeRatesAPI.php to my Wordpress site but they break my site when I do so. Whe I fetch the whole data body using Worpress function wp_remote_get() I can see the expected outcome but I need to show only one rate at a time and take 2 parameters for the 2 currencies so that's why I am trying to use the ExchangeRatesAPI.php functions. Am I doing something wrong or is there any other issue I should be aware of? Thanks in advance for any answer
//https://github.com/benmajor/ExchangeRatesAPI#3-getting-started
require_once 'C:\ExchangeRatesAPI-master\src\ExchangeRatesAPI.php';
$request = wp_remote_get( 'https://api.exchangeratesapi.io/latest?base=USD' );
if( is_wp_error( $request ) ) {
return false; // Bail early
}
$body = wp_remote_retrieve_body( $request );
$data = json_decode( $body );
//echo "<pre>"; //this is for cleaning the data in visualitation
//print_r($data); //print output
use \BenMajor\ExchangeRatesAPI\ExchangeRatesAPI;
use \BenMajor\ExchangeRatesAPI\Response;
use \BenMajor\ExchangeRatesAPI\Exception;
$lookup = new ExchangeRatesAPI();
$base = $lookup->getBaseCurrency();
function mytest(){
$base=getBaseCurrency();
return $base;}
add_shortcode( 'base', 'mytest' );
Version: 4.2.0
After upgrading from v3 to v4, fetching exchange rate on a specific date does not work, using code below:
$lookup = new ExchangeRatesAPI($key, false);
$lookup->setBaseCurrency('USD');
$lookup->addRate('EUR');
$lookup->setFetchDate('2024-01-01');
$rates = $lookup->fetch();
Exception:
BenMajor\ExchangeRatesAPI\Exception
Undefined property: stdClass::$timestamp
It seems, using this, the $date is used as API endpoint, as per
ExchangeRatesAPI/src/ExchangeRatesAPI.php
Line 379 in e545948
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.