我一直在尝试使用 PHP 中的谷歌金融转换器转换货币。
我使用了以下代码。
$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);
?>
但我收到以下错误
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
如何修复此错误?