Currency converter in php code




















Now its working! Your email address will not be published. Save my name, email, and website in this browser for the next time I comment. Just go through Google currency API, you will get verything. Sorry Typos. Should have been: Looks like Google made a change because my script similar to yours stopped working as has yours.

I have updated demo and tutorial and now its working. There was issue from Google Finance Api. BTW: Thanks for your script. Yes Google currency api service stopped now. I will update when it will get fixed. Add a comment. Active Oldest Votes. Sharanya Dutta Sharanya Dutta 3, 2 2 gold badges 14 14 silver badges 27 27 bronze badges. Sparkup Sparkup 3, 2 2 gold badges 33 33 silver badges 49 49 bronze badges. Sign up or log in Sign up using Google.

Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. Stack Gives Back If you purchased a premium plan you can easily change the source currency using the 'source' parameter, if you are using the free plan I will show you how to do a secondary conversion shortly. If we only have the free plan, then this will not be much use to us.

We will receive an error that our plan does not support this feature. To get the results we are after, we will have to perform a secondary conversion based on conversion rates for the US Dollar. Don't worry, it is easier than it sounds. The currencyLayer API provides a 'convert' endpoint to calculate the conversion from one currency to another.

This endpoint is only available in premium plans, however the class also provides a method for this conversion which can be used by us frugal users for free. This will convert 10 US Dollars to Australian Dollars which we can access through the following property values, the result will contain the conversion value. We are using the convertCurrency method with the amount and currency to convert to which will return our conversion value.

We can use the 'historical' endpoint to get the conversion rate at the close of the market for any supported currency as far back as the year This endpoint works exactly like the live endpoint except that we also have to supply the date we want the conversion rate for.

Our code would look something like this In this example we are getting the conversion rates for Euro's and British Pounds on April 15th of The 'timeframe' endpoint is available to Professional and Enterprise premium plan users. The 'change' endpoint is only available to Enterprise premium plan users. As you can see, we can do quite a bit with our free access to the currencyLayer services since we can get both live and historical data.

If you need more than 1, API accesses in a month then you will need to select the premium plan that best suits your needs. If you want the quotes updated every 10 minutes then you will need the professional plan or updated every 60 seconds will require the enterprise plan. While free is always nice, it is also important to remember that our clients or businesses that use the service extensively support our casual free use through premium plans.

If you like this article share with other developers that may want to know about a good currency conversion solution.



0コメント

  • 1000 / 1000