Build Currency Converter in PHP with Google API

Today, We want to share with you google currency converter api php.In this post we will show you free currency converter api php, hear for live currency converter in php we will give you demo and example for implement.In this post, we will learn about All Coins And Cryptocurrency Data API PHP, Ruby, Python with an example.

google currency converter api php

here in this Example You learn All About Example of currency converter in php source code, google finance converter api, currency converter api android with demo and full source code.

Step 1: Creare Currency Convert HTML Form

Example: Build Currency Converter in PHP - www.pakainfo.com

Step 2: Handle Currency Form Submit with Ajax

$('document').ready(function() {	
	$("#money-convert-form").validate({
		rules: {
			amount: {
				required: true,
			},
		},
		messages: {
			amount:{
			  required: ""
			 },			
		},
		submitHandler: moneyConvertFormSubmit	
	});	
	function moneyConvertFormSubmit() {		
		var data = $("#money-convert-form").serialize();				
		$.ajax({				
			type : 'POST',
			url  : 'convert_money.php',
			dataType:'json',
			data : data,
			beforeSend: function(){					
			},
			success : function(response){				
			}
		});
		return false;
	}   
});

Step 3: Convert currency into another currency with Google Currency API

 '1');
		echo json_encode( $data );	
		exit;
	}
	$converted_money=convertCurrency($money_from, $money_to, $amount);
	echo $converted_money;
}
?>

Step 4: Create currency convert function

function convertCurrency($money_from,$money_to,$convert_amount) {	
	$money_from = urlencode($money_from);
	$money_to = urlencode($money_to);	
	$moneyUrl = "https://www.google.com/search?q=".$money_from."+to+".$money_to;
	$moneyDetails = file_get_contents($moneyUrl);
	$moneyData = preg_split('/\D\s(.*?)\s=\s/',$moneyDetails);
	$conversion_rate = (float) substr($moneyData[1],0,7);	
	$total_converted_money_amount = $convert_amount*$conversion_rate;
	$moneyJsonData = array( 'rate' => $conversion_rate, 'total_converted_money_amount' =>$total_converted_money_amount, 'money_from' => strtoupper($money_from), 'money_to' => strtoupper($money_to));
	echo json_encode( $moneyJsonData );	
}

I hope you get an idea about google currency converter api javascript.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Leave a Comment