Change API currency switching provider in Joomla Component (php)
$10-30 USD
Maksettu toimituksen yhteydessä
Component has the option to work with two currency converter provider, Yahoo Finance and Fixer.io.
Yahoo is deprecated and [url removed, login to view] does not have the currency I need. Then I need to add a third currency converter provider:
[url removed, login to view]
*/
private function callProviderYahoo()
{
//[url removed, login to view]
$apis_url = '[url removed, login to view]'. $this->from_currency . $this->to_currency .'=X';
$fp = @fopen($apis_url, 'r');
if ($fp) {
$data = '';
while (!feof($fp)) {
$data .= fread($fp, 4096);
}
if (!empty($data)) {
$data = str_replace("\"", "", $data);
$rate_info = explode(',', $data);
if (strlen($rate_info[1]) > 0 && floatval($rate_info[1]) > 0.00) {
return (float)$rate_info[1];
}
}
}
return false;
}
/**
* Call to the Fixer Foreign exchange rates and currency conversion API.
* Retrieve the conversion rate between base currency and symbol currency.
*
* @return mixed false in case of errors, float in case of success
*/
private function callProviderFixer()
{
//[url removed, login to view]
$apis_url = '[url removed, login to view]'.($this->from_currency != 'EUR' ? 'base='.$this->from_currency.'&' : '').'symbols='.$this->to_currency;
$fp = @fopen($apis_url, 'r');
if ($fp) {
$data = '';
while (!feof($fp)) {
$data .= fread($fp, 4096);
}
$resp = json_decode($data);
if (is_object($resp) && property_exists($resp, 'rates') && is_object($resp->rates)) {
$prop = $this->to_currency;
if (property_exists($resp->rates, $prop) && floatval($resp->rates->$prop) > 0.00) {
return (float)$resp->rates->$prop;
}
}
}
return false;
}
Projektin tunnus: #15726937
Tietoa projektista
3 freelanceria on tarjonnut keskimäärin $33 tähän työhön
Hello there, we have a team that can do the task for you we specially work on PHP. Will be waiting for your reply to proceed. Thank you Have a great day! Sharath@techweblabs team