Poor mans currency conversion
Posted on July 3, 2007
I recently completed a project that required currency conversion. I was limited what I could get out through the corporate firewall, so I came up with this.
It connects to Yahoo! with curl and reads a CSV string into memory.
This example shows how many JPY (Yen) are in 1 GBP (Sterling).
$ch = curl_init('http://finance.yahoo.com/d/quotes.csv?s=JPYGBP=X&f=sl1d1t1ba&e=.csv');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$currency = curl_exec($ch);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_NOPROGRESS,1);
curl_exec($ch);
echo curl_error($ch);
curl_close($ch);
It will return something like this
"JPYGBP=X",0.0041,"7/3/2007","5:16pm",0.0041,0.0041
Related posts
- Yahoo Term Extractor
A recent project I was working on cause me to stumble over the Yahoo Term... - [Snippet] Formatting a currency string
The Shopp ecommerce plugin for WordPress has a little annoying "feature" that returns the product... - [Snippet] Simplified UK/US Date Conversion
One of my major annoyances in PHP & MySQL world is the different formats when... - Yahoo GeoLocation API
The Yahoo Maps API is the best API I've found for using on in internal... - Extra Cover Cricket
I wrote the Extra Cover Cricket site about a year ago to provide a central...



May 8th, 2011 - 18:12
This is a strange post. Yeahh I like this strange post. I will read a lot in this page