I have been trying to convert the currencies using google finance converter in PHP.
I have used the following code.
$amount = 100;
$from_Currency = "INR";
$to_Currency = "BTC";
$amount = urlencode($amount);
$from_Currency = urlencode($from_Currency);
$to_Currency = urlencode($to_Currency);
$get = file_get_contents("https://finance.google.com/finance/converter?a=$amount&from=$from_Currency&to=$to_Currency&meta=ei%3DZsa7WeGkE4_RuASY95SQAw");
$get = explode("<span class=bld>",$get);
$get = explode("</span>",$get[1]);
$converted_amount = preg_replace("/[^0-9\.]/", null, $get[0]);
echo ceil($converted_amount);
?>
But i am getting the following error
Warning: file_get_contents(https://finance.google.com/finance/converter?a=100&from=INR&to=BTC&meta=ei%3DZsa7WeGkE4_RuASY95SQAw): failed to open stream: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. in F:\Xampp\htdocs\test\index.php on line 11
Notice: Undefined offset: 1 in F:\Xampp\htdocs\test\index.php on line 16
0
How to fix this error?
I had the same problem. I think that google has changed way to output the result. Try this (works for me, tested today at 12.14 PM CEST (UTC+2))