Widget no longer works!

My widget has suddenly stopped working and hope that you can help me sort it out.

My understanding (as the basic code is not mine) is that the up-to-date currencies were downloaded by the following very long url

http://query.yahooapis.com/v1/public/yql?q=select * from yahoo.finance.xchange where pair in ( “EURAED”,“EURARS”,“EURAUD”,“EURAWG”,“EURBAM”,“EURBBD”,“EURBDT”,“EURBGN”,“EURBHD”,“EURBMD”,“EURBOB”, “EURBRL”,“EURBSD”,“EURCAD”,“EURCHF”,“EURCLP”,“EURCNY”,“EURCOP”,“EURCYP”,“EURCZK”,“EURDKK”,“EURDOP”, “EUREGP”,“EUREUR”,“EURFJD”,“EURGBP”,“EURGHS”,“EURGMD”,“EURGTQ”,“EURHKD”,“EURHRK”,“EURHUF”,“EURIDR”, “EURILS”,“EURINR”,“EURIRR”,“EURISK”,“EURJMD”,“EURJOD”,“EURJPY”,“EURKES”,“EURKHR”,“EURKRW”,“EURKWD”, “EURLAK”,“EURLBP”,“EURLKR”,“EURLTL”,“EURLVL”,“EURMAD”,“EURMDL”,“EURMGA”,“EURMKD”,“EURMUR”,“EURMVR”, “EURMXN”,“EURMYR”,“EURNAD”,“EURNGN”,“EURNOK”,“EURNPR”,“EURNZD”,“EUROMR”,“EURPAB”,“EURPEN”,“EURPHP”, “EURPKR”,“EURPLN”,“EURPYG”,“EURQAR”,“EURRON”,“EURRSD”,“EURRUB”,“EURSAR”,“EURSCR”,“EURSEK”,“EURSGD”, “EURSYP”,“EURTHB”,“EURTND”,“EURTRY”,“EURTWD”,“EURUAH”,“EURUGX”,“EURUSD”,“EURUYU”,“EURVEF”,“EURVND”, “EURXAF”,“EURXCD”,“EURXOF”,“EURXPF”,“EURZAR”)&env=store://datatables.org/alltableswithkeys

I remember pasting it in the address bar and getting the expected exchange rates.

It no longer works…

I can only think of 3 possibilities:

a) I have been banned: unlikely, as I took steps to obtain permission to use the API and eventually read that it is free to use up to acertain level that I will never reach…

b) The API is out of order and awating repair: unilikely as it has now been a few days since it stopped working

c) Yahoo has changed the code: this is where I hope you can help getting it to work again

I have done some investigating and saw this Yahoo own widget at https://finance.yahoo.com/currency-converter/#from=USD;to=EUR;amt=1

Looking at the source code for the page I see some parallels to the code for my widget and think that my code was copied from something similar.

I extracted from the source code the following:

https://finance.yahoo.com/webservice/v1/symbols/allcurrencies/quote;currency=true?view=basic&format=json&callback=YAHOO.Finance.CurrencyConverter.addConversionRates

which produces something that may be all I need to replace my present code with this.

Please, let me know if you can help and what else you may need. You can see the widget in the sidebar of this test page:

http://pintotours.net/TEMP1/ZRH.html

Thank you

LATER EDIT

When I enter in the address bar the location of the php file that controls the widger I get load of warnings that I do not understand…

http://pintotours.net/scripts/converter5.php

Is the XML file you get back in a proper format? The warning for simplexml_load_file may well be because the returned information isn’t in a good XML format, and if you don’t handle that the remaining warnings might be because you’ve assumed you’re getting good data and not dealt with potential errors. In particular the foreach() error might stem from not being able to parse the XML. Without seeing your code it’s impossible to comment on the warnings. If you’ve obtained permission to use the API, presumably there’s some kind of developer site that you could access to check if anything has changed?

1 Like

Hi droopsnoot

First, let me tell you that I had the code written for me and I do not understand it… Html/css I get by, php is Chinese to me.

Second, this code worked very well for over 6 months and I suspect that Yahoo changed their widget and that my code was “pirated” from an earlier version.

So, what I need to know now is whether it is possible to use the new code (if that’s what I found in the “View Source” of their new widget to patch my php file, but I wouldn’t know where to start!

Could you help me there?

Thanks

I had a quick look at their page, but you don’t see the PHP source code in a “View Source” operation, as PHP is executed only on the server.

If I run a small cut-down query from the address bar, I get the expected results, so I can’t say why it’s not functioning in your code.

Do you mean this url?

what would I have to do to get it working on my php file?

No, I was talking about where you typed this:

The code you see in View Source is the html/css and JavaScript (possibly, I haven’t looked through all of it as it’s massive) - PHP doesn’t show up in there. If you wanted to convert it to replace your PHP, then it’s a language translation, not something that can be automated.

Can you post your PHP code, with any sensitive data like passwords removed?

What I found was the above to which I added https://finance.yahoo.com and did get results. But can I use them in my file, and if so, how?

On line 597 you get this

<script type="text/javascript" src="/webservice/v1/symbols/allcurrencies/quote;currency=true?view=basic&format=json&callback=YAHOO.Finance.CurrencyConverter.addConversionRates"></script>

<?php
$xml=simplexml_load_file('http://query.yahooapis.com/v1/public/yql?q=select * from yahoo.finance.xchange where pair in (
"EURAED","EURARS","EURAUD","EURAWG","EURBAM","EURBBD","EURBDT","EURBGN","EURBHD","EURBMD","EURBOB",
"EURBRL","EURBSD","EURCAD","EURCHF","EURCLP","EURCNY","EURCOP","EURCYP","EURCZK","EURDKK","EURDOP",
"EUREGP","EUREUR","EURFJD","EURGBP","EURGHS","EURGMD","EURGTQ","EURHKD","EURHRK","EURHUF","EURIDR",
"EURILS","EURINR","EURIRR","EURISK","EURJMD","EURJOD","EURJPY","EURKES","EURKHR","EURKRW","EURKWD",
"EURLAK","EURLBP","EURLKR","EURLTL","EURLVL","EURMAD","EURMDL","EURMGA","EURMKD","EURMUR","EURMVR",
"EURMXN","EURMYR","EURNAD","EURNGN","EURNOK","EURNPR","EURNZD","EUROMR","EURPAB","EURPEN","EURPHP",
"EURPKR","EURPLN","EURPYG","EURQAR","EURRON","EURRSD","EURRUB","EURSAR","EURSCR","EURSEK","EURSGD",
"EURSYP","EURTHB","EURTND","EURTRY","EURTWD","EURUAH","EURUGX","EURUSD","EURUYU","EURVEF","EURVND",
"EURXAF","EURXCD","EURXOF","EURXPF","EURZAR")&env=store://datatables.org/alltableswithkeys');
//simplexml_load_file('yql.xml');
$r=[];

foreach($xml->results->rate as $node) {
foreach($node->Rate as $node0) {
  array_push($r,$node0);
 }
}
foreach($xml->results->rate->Date as $node) {
  $date="'$node'";
 }
foreach($xml->results->rate->Time as $node) {
  $time="'$node EST'";
 }

$end=count($r)-1;

?>

Hi there qim,

it appears that this…

http://query.yahooapis.com/v1/public/yql?q=select * from yahoo.finance.xchange where pair in ( 
"EURAED","EURARS","EURAUD","EURAWG","EURBAM","EURBBD","EURBDT","EURBGN","EURBHD","EURBMD","EURBOB", 
"EURBRL","EURBSD","EURCAD","EURCHF","EURCLP","EURCNY","EURCOP","EURCYP","EURCZK","EURDKK","EURDOP", 
"EUREGP","EUREUR","EURFJD","EURGBP","EURGHS","EURGMD","EURGTQ","EURHKD","EURHRK","EURHUF","EURIDR", 
"EURILS","EURINR","EURIRR","EURISK","EURJMD","EURJOD","EURJPY","EURKES","EURKHR","EURKRW","EURKWD", 
"EURLAK","EURLBP","EURLKR","EURLTL","EURLVL","EURMAD","EURMDL","EURMGA","EURMKD","EURMUR","EURMVR", 
"EURMXN","EURMYR","EURNAD","EURNGN","EURNOK","EURNPR","EURNZD","EUROMR","EURPAB","EURPEN","EURPHP", 
"EURPKR","EURPLN","EURPYG","EURQAR","EURRON","EURRSD","EURRUB","EURSAR","EURSCR","EURSEK","EURSGD", 
"EURSYP","EURTHB","EURTND","EURTRY","EURTWD","EURUAH","EURUGX","EURUSD","EURUYU","EURVEF","EURVND", 
"EURXAF","EURXCD","EURXOF","EURXPF","EURZAR")&env=store://datatables.org/alltableswithkeys

… will only work for 50 rates rather than the full 88. :cold_sweat:

“Results may be truncated because the run exceeded
the allowed max response timeout of 30000ms.”

Whether this is temporary or not, I cannot say. :mask:

Does your site really need the full list or could you select 38 to remove?

coothead

Ah, I wondered about that - it worked perfectly when I tried typing a couple of them in but I get the same timeout error. Maybe a change to the code to do the first half, then the second half, would do it. Yes, if I truncate the list after EURLVL, the call returns without any errors, so the thing to do would be to call with the smaller list, build the $r array, then call again with the second half of the list. I don’t know what the final two foreach() calls do, they just seem to iterate through the xml results and repeatedly set the same variable to a value.

So maybe something like this at the start of the code:

<?php

// get the first set of data

$xml=simplexml_load_file('http://query.yahooapis.com/v1/public/yql?q=select * from yahoo.finance.xchange where pair in ("EURAED","EURARS","EURAUD","EURAWG","EURBAM","EURBBD","EURBDT","EURBGN","EURBHD","EURBMD",
"EURBOB","EURBRL","EURBSD","EURCAD","EURCHF","EURCLP","EURCNY","EURCOP","EURCYP","EURCZK",
"EURDKK","EURDOP","EUREGP","EUREUR","EURFJD","EURGBP","EURGHS","EURGMD","EURGTQ","EURHKD","EURHRK",
"EURHUF","EURIDR","EURILS","EURINR","EURIRR","EURISK","EURJMD","EURJOD","EURJPY","EURKES","EURKHR","EURKRW","EURKWD",
"EURLAK","EURLBP","EURLKR","EURLTL","EURLVL")&env=store://datatables.org/alltableswithkeys');
//simplexml_load_file('yql.xml');
$r=[];

foreach($xml->results->rate as $node) {
foreach($node->Rate as $node0) {
  array_push($r,$node0);
 }
}

// Now get the second set of results

$xml=simplexml_load_file('http://query.yahooapis.com/v1/public/yql?q=select * from yahoo.finance.xchange where pair in (
"EURMAD","EURMDL","EURMGA","EURMKD","EURMUR","EURMVR",
"EURMXN","EURMYR","EURNAD","EURNGN","EURNOK","EURNPR","EURNZD","EUROMR","EURPAB","EURPEN","EURPHP",
"EURPKR","EURPLN","EURPYG","EURQAR","EURRON","EURRSD","EURRUB","EURSAR","EURSCR","EURSEK","EURSGD",
"EURSYP","EURTHB","EURTND","EURTRY","EURTWD","EURUAH","EURUGX","EURUSD","EURUYU","EURVEF","EURVND",
"EURXAF","EURXCD","EURXOF","EURXPF","EURZAR")&env=store://datatables.org/alltableswithkeys');

// loop again to add them to the array we created earlier.

foreach($xml->results->rate as $node) {
foreach($node->Rate as $node0) {
  array_push($r,$node0);
 }
}

// then carry on with the rest of the code

It really needs some error-checking in there, to behave a bit more nicely if the data doesn’t come through.

Hi coothead

Well, yes, at the moment I could reduce the number. How do I do that? delete 38 pairs? and leave eveything else in place?

Does that mean that the other possibility of the other code that ) found is not viable?

<script type="text/javascript" src="/webservice/v1/symbols/allcurrencies/quote;currency=true?view=basic&format=json&callback=YAHOO.Finance.CurrencyConverter.addConversionRates"></script>

Hi droopsnoot

Let me reduce the number of pairs first as suggested by coothead to get the widget working properly again. Then I will test your solution which seems more permanent.

Thanks

Hi there qim,

oooops, just thinking aloud. :cold_sweat:

coothead

I’m half-way through deleting currencies…

Is it working in http://pintotours.net/TEMP1/ZRH.html ?

It doesn’t work on any of my pages with the original code.

Hi there qim,

sorry about my previous post, had a “brain fart”
and forgot that I had removed 38 items. :arrow_heading_down: :ng:

coothead

Well, I can’t really go below 65 but forced it down to 47, and still does not work…

<?php
$xml=simplexml_load_file('http://query.yahooapis.com/v1/public/yql?q=select * from yahoo.finance.xchange where pair in (
"EURAED","EURARS","EURAUD","EURBGN","EURBHD","EURBOB",
"EURBRL","EURCAD","EURCHF","EURCLP","EURCNY","EURCOP","EURCZK","EURDKK","EURDOP",
"EUREGP","EUREUR","EURGBP","EURGTQ","EURHKD","EURHRK","EURHUF","EURIDR",
"EURILS","EURINR","EURISK","EURJMD","EURJOD","EURJPY","EURKRW","EURKWD",
"EURLBP","EURLKR","EURLTL","EURLVL","EURMKD",
"EURMXN","EURMYR","EURNOK","EURNZD","EUROMR","EURPAB","EURPEN","EURPHP",
"EURXAF","EURXCD","EURZAR")&env=store://datatables.org/alltableswithkeys');
//simplexml_load_file('yql.xml');
$r=[];

foreach($xml->results->rate as $node) {
foreach($node->Rate as $node0) {
  array_push($r,$node0);
 }
}
foreach($xml->results->rate->Date as $node) {
  $date="'$node'";
 }
foreach($xml->results->rate->Time as $node) {
  $time="'$node EST'";
 }

$end=count($r)-1;

?>

Hi

I tried putting the first part in the address bar and yes, I got a result, but it took ages. During the months when the code worked fine it was instantaneous.

Now that I see the api working (badly…), I assume there is a problem on Yahho’s side. Are they trying to sort it out?..

I wonder if there is an alternative to this api.

http://query.yahooapis.com/v1/public/yql?q=select * from yahoo.finance.xchange where pair in (“EURAED”,“EURARS”,“EURAUD”,“EURAWG”,“EURBAM”,“EURBBD”,“EURBDT”,“EURBGN”,“EURBHD”,“EURBMD”,
“EURBOB”,“EURBRL”,“EURBSD”,“EURCAD”,“EURCHF”,“EURCLP”,“EURCNY”,“EURCOP”,“EURCYP”,“EURCZK”,
“EURDKK”,“EURDOP”,“EUREGP”,“EUREUR”,“EURFJD”,“EURGBP”,“EURGHS”,“EURGMD”,“EURGTQ”,“EURHKD”,“EURHRK”,
“EURHUF”,“EURIDR”,“EURILS”,“EURINR”,“EURIRR”,“EURISK”,“EURJMD”,“EURJOD”,“EURJPY”,“EURKES”,“EURKHR”,“EURKRW”,“EURKWD”,
“EURLAK”,“EURLBP”,“EURLKR”,“EURLTL”,“EURLVL”)&env=store://datatables.org/alltableswithkeys

It did take quite a long time to respond, but I had nothing to compare it to so I didn’t know whether that was slower or quicker. But with that code I posted that does two separate requests, I ended up with 92 entries in the $r array.

Hi droopsnoot

Well the widget until last week took a few milisecs to load. very very fast!

Did you look at the other alternative in my opening post?

Thanks