I have been looking around Yahoo Developer Network for this but found nothing relating to using the Currency Converter API.
You can make something similar to convert any currency to another currency using the Yahoo! database!
Here is what I came up with:
< ?php $from = 'USD'; //US Dollar $to = 'PHP'; //to Philippine Peso $url = 'http://finance.yahoo.com/d/quotes.csv?e=.csv&f=sl1d1t1&s='. $from . $to .'=X'; $handle = @fopen($url, 'r'); if ($handle) { $result = fgets($handle, 4096); fclose($handle); } $array = explode(',',$result); var_dump($array); /* OUTPUTS: array(4) { [0]=> string(10) ""USDPHP=X"" [1]=> string(6) "47.125" [2]=> string(11) ""10/3/2008"" [3]=> string(10) ""5:03pm" " } */ |
This is the simplest example I could give. And it works!
bert ako ni gamiton ha kay nangita pud ko ani hehehe thanks master kaayo ka bai
Wonderfull dude, i was looking for this. Thanks a lot.
Yep just what I needed – thanks!
It’s gr8 .. this is what I am looking for.
Do you have any idea about the currency type it support? Also, can i use this frequently? I mean is yahoo allow me to request this URL thousand times a day?
@ashish You can go to their finance website see what types of currencies they support. But I am guessing they can convert any currency.
Yahoo has unlimited resources so you can use this as much as you want. But the smart thing to do is to “fetch” the data and store it in your database – you can use a cronjob to automatically fetch the currencies – autofetch the data every 30 minutes. Then, you query your database instead of querying Yahoo for every request. It will be safer this way.
Thanks Wenbert for your help and suggestion.
Thanks dude its working
Thanks a lot. I am searching for a long time
Brilliant. Exactly what I was looking for
Maraming salamat bro!!! been looking for this all over.
Thank u, Its help full lot, If u want to convert 3USD to INR, then where the logic is? Please its urgent
@satish you simply multiply the output by 3? To be sure just try out the code
Thank you its very helpful
Hello Friends,
Is their a single URL bu which I can fetch the exchange rates of all the currency??
I mean I send one URL and response should be base currency and all other currency in its respect…
Thanks
@chits, I am not sure. But using the single URL, i would store the values in my database then update my database with a cronjob. It would also be faster on your side because you will be querying your own database instead of the URL.
Thanks Wenbert,
Actually I was making a application(currency converter) which supports many currencies..now the suggestion is good but the only problem is I have to make multiple request in a loop (when doing currency update) and keep track of all of the request..in a way a bit more of work ..
Thanks, perfect for those automated collection of Exchange rates!
Thanks,
I’m looking similar to this for long..
Thanks
how can i send price value in the url? for example in the above example if i want to check 2USD in PHP then how can i send 2 in the url?
Thanks..
Very useful.Just what I need.
Ang ganda ng code mo! Salamat!
Thanks for your example, I used it in my ucc eggdrop tcl script.
Good.
Excelente Recurso…
How to get currency symbol?
thanks for this. I really need this.
Pingback: Yahoo Finance – Converting Currencies « iDeveloper Notes