Search in This Blog

Currency convertor


Some time you need to convert currency into different countries, so what you will do?


You can use yahooapi


Use below code. the code is in PHP ou can easily convert it into VB.Net, Java, C# etc if you are good programmer.

function curr_convert($ffrom,$tto,$iinput) {
$yql_url = "";
    $yql_query = 'select * from where pair in ("'.$ffrom.$tto.'")';
    $yql_query_full_url = $yql_url . "?q=" . urlencode($yql_query);
    $yql_query_full_url .= "&format=json&";
    $yql_curl = curl_init($yql_query_full_url);
    curl_setopt($yql_curl, CURLOPT_RETURNTRANSFER,true);
    $yqlcurl_exec = curl_exec($yql_curl);
    $yql_json =  json_decode($yqlcurl_exec,true);
    $curr_output = (float) $iinput*$yql_json['query']['results']['rate']['Rate'];
    return $curr_output;
$result = curr_convert($ffrom = "USD", $tto = "INR", $iinput = 1);
echo '1 USD  = '.$result.' INR';