webERP Forum
Currencies Maintenance: graphs no longer work - Printable Version

+- webERP Forum (http://www.weberp.org/forum)
+-- Forum: webERP Discussion (http://www.weberp.org/forum/forumdisplay.php?fid=1)
+--- Forum: Problems / Bugs? (http://www.weberp.org/forum/forumdisplay.php?fid=8)
+--- Thread: Currencies Maintenance: graphs no longer work (/showthread.php?tid=8002)



Currencies Maintenance: graphs no longer work - HDeriauFF - 12-22-2017

Not critical, but currencies graphs are no longer displayed as Google seems to have updated its API for these:

Setup > Currencies maintenance : click on "Graph" for the currency that is not a "functional" one: displays a broken image

Thank you for looking into this


RE: Currencies Maintenance: graphs no longer work - falkoner - 12-22-2017

Yeah the Google api calls no longer work. I wrote a function to use another provider. I will upload the function later when I am I front of a computer

Tim


RE: Currencies Maintenance: graphs no longer work - HDeriauFF - 12-22-2017

Great, Thank you Tim!


RE: Currencies Maintenance: graphs no longer work - falkoner - 12-22-2017

Below is my yahoo function. It would be really nice if anybody knows of an open data source for this information where the APIs wouldn't get arbitrarily removed or changed regularly.

Tim

function yahoo_currency_rate($CurrCode) {
if (http_file_exists('https://finance.yahoo.com/webservice/v1/symbols/allcurrencies/quote')) {
$xml = file_get_contents('https://finance.yahoo.com/webservice/v1/symbols/allcurrencies/quote');
$parser = xml_parser_create();
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
xml_parse_into_struct($parser, $xml, $tags);
xml_parser_free($parser);

$elements = array(); // the currently filling [child] XmlElement array
$stack = array();
foreach ($tags as $tag) {
$index = count($elements);
if ($tag['type'] == 'complete' or $tag['type'] == 'open') {
$elements[$index] = new XmlElement;
$elements[$index]->name = $tag['tag'];
if (isset($tag['attributes'])) {
$elements[$index]->attributes = $tag['attributes'];
}
if (isset($tag['value'])) {
$elements[$index]->content = $tag['value'];
}
if ($tag['type'] == 'open') { // push
$elements[$index]->children = array();
$stack[count($stack)] =& $elements;
$elements =& $elements[$index]->children;
}
}
if ($tag['type'] == 'close') { // pop
$elements =& $stack[count($stack) - 1];
unset($stack[count($stack) - 1]);
}
}
$Currencies = array();
foreach ($elements[0]->children[1]->children as $CurrencyDetails) {
foreach ($CurrencyDetails as $CurrencyDetail) {
if (is_array($CurrencyDetail) and isset($CurrencyDetail[0])) {
$Currencies[mb_substr($CurrencyDetail[0]->content, 4)] = $CurrencyDetail[1]->content;
}
}
}
$Currencies['USD'] = 1; //ECB delivers no rate for Euro
//return an array of the currencies and rates
return $Currencies;
} else {
return false;
}
}



RE: Currencies Maintenance: graphs no longer work - HDeriauFF - 12-24-2017

(12-22-2017, 09:05 AM)falkoner Wrote: Below is my yahoo function. It would be really nice if anybody knows of an open data source for this information where the APIs wouldn't get arbitrarily removed or changed regularly.

Tim

function yahoo_currency_rate($CurrCode) {
if (http_file_exists('https://finance.yahoo.com/webservice/v1/symbols/allcurrencies/quote')) {
$xml = file_get_contents('https://finance.yahoo.com/webservice/v1/symbols/allcurrencies/quote');
$parser = xml_parser_create();
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
xml_parse_into_struct($parser, $xml, $tags);
xml_parser_free($parser);

$elements = array(); // the currently filling [child] XmlElement array
$stack = array();
foreach ($tags as $tag) {
$index = count($elements);
if ($tag['type'] == 'complete' or $tag['type'] == 'open') {
$elements[$index] = new XmlElement;
$elements[$index]->name = $tag['tag'];
if (isset($tag['attributes'])) {
$elements[$index]->attributes = $tag['attributes'];
}
if (isset($tag['value'])) {
$elements[$index]->content = $tag['value'];
}
if ($tag['type'] == 'open') { // push
$elements[$index]->children = array();
$stack[count($stack)] =& $elements;
$elements =& $elements[$index]->children;
}
}
if ($tag['type'] == 'close') { // pop
$elements =& $stack[count($stack) - 1];
unset($stack[count($stack) - 1]);
}
}
$Currencies = array();
foreach ($elements[0]->children[1]->children as $CurrencyDetails) {
foreach ($CurrencyDetails as $CurrencyDetail) {
if (is_array($CurrencyDetail) and isset($CurrencyDetail[0])) {
$Currencies[mb_substr($CurrencyDetail[0]->content, 4)] = $CurrencyDetail[1]->content;
}
}
}
$Currencies['USD'] = 1; //ECB delivers no rate for Euro
//return an array of the currencies and rates
return $Currencies;
} else {
return false;
}
}


how about this one:? did anybody try it?

https://openexchangerates.org