Currency converter using php curl ajax bootstrap

Hello firends today i will show you how to convert the currency from one country to another country. Getting live currency rates  is one of the headache of developers. So here i have collected the live currency  code, using which you can get the live currency rates from google finance APi. The code is written in php jquery, ajax, curl. Through this software we can convert morethan 200 foreign currency cross rates at todays exchange. Through this tutorial you can also learn about bootstrap price slider and its working process.


Jquery Ajax Code:

Included hpb_converter.php file contains a function which send HTTP request and return response back.

PHP Code :

function hpb_currency_converter($hpb_from_currency, $hpb_to_currency, $hpb_amount)
	$hpb_set_timeout = 0;
	$hpb_amount = urlencode($hpb_amount);
	$hpb_from_currency = urlencode($hpb_from_currency);
	$hpb_to_currency = urlencode($hpb_to_currency);
	$url = "http://www.google.com/finance/converter?a=$hpb_amount&from=$hpb_from_currency&to=$hpb_to_currency";

	$hpb_init_set = curl_init();
	curl_setopt ($hpb_init_set, CURLOPT_URL, $url);
	curl_setopt ($hpb_init_set, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt ($hpb_init_set, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)");
	curl_setopt ($hpb_init_set, CURLOPT_CONNECTTIMEOUT, $hpb_set_timeout);
	$hpb_execution = curl_exec($hpb_init_set);
	$hpb_executed_info = explode('bld>', $hpb_execution);
	$hpb_executed_info = explode($hpb_to_currency, $hpb_executed_info[1]);

	return round($hpb_executed_info[0], 2);

	echo $amount = number_format(hpb_currency_converter($from_currency,$to_currency,$amount), 2);

I hope you like my tutorial. To see the full concept of the tutorial, kindly subscribe and download the code. Contact me and let me know if there is any feedback.

By posted on - 15th Feb 2016