1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

currency converter API

Discussion in 'Programming' started by i_am_dhaval, Sep 30, 2014.

  1. #1
    Hi

    i would like to add currency converter in my one of the website for USD to INR

    when Indian people can get money on direct his bank account and if they pay on site then it will show 100$ = this much INR

    is any bank provide this type of API ?

    or any online resources ?

    Thanks
     
    i_am_dhaval, Sep 30, 2014 IP
  2. huyhoa

    huyhoa Active Member

    Messages:
    214
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #2
    you should use Google currency convert tool.
    This is function to do it in PHP
    
    function currencyConvert($from,$to,$amount){
      $url = "http://www.google.com/finance/converter?a=$amount&from=$from&to=$to";
      $request = curl_init();
      $timeOut = 0;
      curl_setopt ($request, CURLOPT_URL, $url);
      curl_setopt ($request, CURLOPT_RETURNTRANSFER, 1);
      curl_setopt ($request, CURLOPT_USERAGENT,"Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)");
      curl_setopt ($request, CURLOPT_CONNECTTIMEOUT, $timeOut);
      $response = curl_exec($request);
      curl_close($request);
      return $response;
    }
    
    PHP:
    Required: Your host need turn curl on and allow running PHP :D

    Using:
    
    $huyhoaData = currencyConvert($from,$to,$amount);
    $regex    = '#\<span class=bld\>(.+?)\<\/span\>#s';
    preg_match($regex, $huyhoaData, $dataex);
    $show = $dataex[0];
    echo $show;
    
    PHP:
    Where $from = currency code of original currency
    $to = converted currency.
    In your case, $from = 'USD';
    $to = 'INR'; //Indian Rupee (Rs.)
    $amount = 'numeric amount want to change';
     
    Last edited: Oct 1, 2014
    huyhoa, Oct 1, 2014 IP
  3. i_am_dhaval

    i_am_dhaval Well-Known Member

    Messages:
    1,364
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    138
    #3
    but we bank give different rate then google show what can i do for that ?
     
    i_am_dhaval, Oct 1, 2014 IP
  4. Harshal shah

    Harshal shah Active Member

    Messages:
    126
    Likes Received:
    5
    Best Answers:
    1
    Trophy Points:
    65
    #4
    Hi Dhaval,

    Bank will give different rates, and that is not fix. we can negotiate with bank. what is your purpose? Bank rate would vary 15 to 20 paisa.
     
    Harshal shah, Oct 9, 2014 IP
  5. i_am_dhaval

    i_am_dhaval Well-Known Member

    Messages:
    1,364
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    138
    #5
    i_am_dhaval, Oct 9, 2014 IP
  6. Harshal shah

    Harshal shah Active Member

    Messages:
    126
    Likes Received:
    5
    Best Answers:
    1
    Trophy Points:
    65
    #6
    Its on their website. I have its bank account. I got with max 25 paisa difference from xe when I get in my bank.
     
    Harshal shah, Oct 10, 2014 IP
  7. forexguide24

    forexguide24 Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #7
    I don't think there's any bank providing a currency conversion API. I researched this topic a few months ago because I needed a cost-effective alternative to all the expensive providers like "XE":

    I'd highly recommend the currencylayer API - (https://currencylayer.com)

    What they offer:

    - exchange rates for 168 currencies
    - simple currency conversion
    - real-time rates and historical rates
    - a ton of cool features
    - perfect documentation

    What you'll pay:
    Nothing. They have a Free Plan that lets you make 1,000 API Calls per month - and if you need more than that, paid subscriptions are starting at $9.99/month, which is perfectly affordable for startups and smaller online businesses...
     
    forexguide24, May 21, 2015 IP