Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Currencies Maintenance: graphs no longer work
12-22-2017, 04:55 AM (This post was last modified: 12-22-2017 05:07 AM by HDeriauFF.)
Post: #1
Currencies Maintenance: graphs no longer work
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
Find all posts by this user
Quote this message in a reply
12-22-2017, 04:59 AM
Post: #2
RE: Currencies Maintenance: graphs no longer work
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
Visit this user's website Find all posts by this user
Quote this message in a reply
12-22-2017, 05:11 AM
Post: #3
RE: Currencies Maintenance: graphs no longer work
Great, Thank you Tim!
Find all posts by this user
Quote this message in a reply
12-22-2017, 09:05 AM
Post: #4
RE: Currencies Maintenance: graphs no longer work
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;
}
}
Visit this user's website Find all posts by this user
Quote this message in a reply
12-24-2017, 06:33 AM
Post: #5
RE: Currencies Maintenance: graphs no longer work
(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
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)