Using the Google currency converter

For a project I’m working, I needed to get shipping rates from the UPS API (a blog post about this will follow soon).

The problem I ran into was that the UPS API returns the shipping rates with the currency of the country where the rates for are asked, so you can’t force it to always return the rates in EUR.

One solution to convert the prices is to make a very big array with all currency rates in it. I then would maintain the array every day at 9’o clock to check if the rates weren’t changed. Right, that’s not an option.

Like you might know you can easily convert currencies by using the Google search engine. For example searching on “1 Euro to dollar” will retrieve the Euro in dollar.

Below the class I wrote to convert currencies using the Google currency converter.

sConvertorUrl, $this->fPrice, $this->sFrom, $this->sTo);

		$sResponse = file_get_contents($sUrl);
		if(!$sResponse) {
			throw new Exception('Google currency convertor is not available at the moment');
		}

		$oResult = json_decode($sResponse);
		if($oResult->error != '') {
			throw new Exception('The following error occurred: '.$oResult->error);
		}

		// Isolate the price
		return (float)$oResult->rhs;
	}

	/**
	 * Get, retrieve the foreign currency
	 *
	 * @param float $fPrice
	 * @param string $sFrom, currency code (EUR, USD,...)
	 * @param string $sTo, currency code (EUR, USD,...)
	 */
	public function get($fPrice, $sFrom, $sTo)
	{
		if(!is_float($fPrice)) {
			throw new Exception('The price to convert should be a float, "'.gettype($fPrice). '" given while calling: '.__FUNCTION__);
		}

		$this->fPrice	= $fPrice;
		$this->sFrom	= strtoupper($sFrom);
		$this->sTo		= strtoupper($sTo);

		return $this->exec();
	}

}
?>

Pretty straightforward as you see.

Comments

740 responses to “Using the Google currency converter”

  1. git.craigsau.dev Avatar

    References:

    How are steroids administered

    References:
    http://59.110.47.157:3000/amos65p6703547

  2. gitea.nkal.me Avatar

    References:

    Best post cycle therapy for steroids

    References:
    http://172.236.250.154:3000/pabloforlong92

  3. mmctube.com Avatar

    References:

    Non steroid muscle builder

    References:
    http://49.232.183.190:3000/derickeaston5

  4. git.apextoaster.com Avatar

    References:

    Anabolic steroids stacks

    References:
    https://git.4lsa.com/bobv7166877761

  5. movieru.jp Avatar

    References:

    Which one of the following is not a potential danger
    of anabolic steroids?

    References:
    http://154.8.164.149:3000/lavinastrode28

  6. 36.153.162.171 Avatar

    References:

    Best supplements for bodybuilding without side effects

    References:
    https://play.eccentric.etc.br/@qvcwinifred563?page=about

  7. dns.chenzhao.date Avatar

    References:

    Disadvantages of steroids

    References:
    https://www.musicsound.ca/adelemanley678

  8. vlotube.com Avatar

    References:

    Sam e long term use

    References:
    https://ghibta.org/employer/spiropent/

  9. git.erfmann.dev Avatar

    References:

    Did ronnie coleman use steroids

    References:
    https://gitea.ontoast.uk/margheritamacf

  10. www.heyne.cloud Avatar

    References:

    How long does it take to get over steroid withdrawal?

    References:
    https://git.ewengadonnaud.xyz/blancakemble3/8225557/wiki/Spiropent-Fachinformation

  11. mycrewdate.com Avatar

    References:

    The best anabolic steroid

    References:
    https://git.lifetop.net/dorriswagstaff

  12. http://72.61.229.93:4000/malissamcintos Avatar

    References:

    The use of anabolic steroids during adolescence can cause

    References:
    https://git.meshel.cn/brentonscobie

  13. ttym.space Avatar

    References:

    Gnc pro performance whey

    References:
    http://115.190.209.222:3000/shermanyry8041

  14. 101.132.168.104 Avatar

    References:

    Safe steroid cycles

    References:
    http://123.60.146.54:3000/heathercostas0

  15. jobs.assist24-7.com Avatar

    References:

    Closest thing to steroids on the market

    References:
    https://christianmail.tv/@claribelboyer2?page=about

  16. https://hijobber.com Avatar

    References:

    Once growth stunting occurs

    References:
    http://115.159.107.117:3000/ninabdn6931852

  17. uk4mag.co.uk Avatar

    References:

    Pills that make you build muscle fast

    References:
    http://112.74.106.216:3000/jamiecarrol246

  18. repo.magicbane.com Avatar

    References:

    Once growth stunting occurs

    References:
    https://nrimatchmaking.com/@iona35a824608

  19. kingdom casino nz Avatar

    Honest Kingdom Casino NZ review: 200NZ$ bonus for new players, 100 free spins, VIP program, fast withdrawals. Licensed casino for New Zealand.

  20. laviesound.com Avatar

    References:

    Women on steriods

    References:
    http://8.129.11.230:7002/portershields6

  21. gitea.brmm.ovh Avatar

    References:

    Steroid use side effects

    References:
    https://dev01.open-alt.com/dewittpruett2

  22. mkhonto.net Avatar

    References:

    Best steroids in the world

    References:
    https://ripematch.com/@bernd39z284815

  23. nbcmedia.net Avatar

    References:

    15 year old steroids

    References:
    https://exir.tv/@bertiewhitlow?page=about

  24. mindsworks.org Avatar

    References:

    Gnc alpha muscle stack

    References:
    https://vlotube.com/@rebbecaboss894?page=about

  25. https://drarchina.com/ Avatar

    References:

    Anabolic steroids profiles

    References:
    http://47.107.188.236:3000/micaela4143998

Leave a Reply

Your email address will not be published. Required fields are marked *