Php 谷歌金融货币转换器不工作
我使用google finance为currecy converter编写的代码不起作用Php 谷歌金融货币转换器不工作,php,api,codeigniter,google-finance,Php,Api,Codeigniter,Google Finance,我使用google finance为currecy converter编写的代码不起作用 $amount="10"; $from="USD"; $to="INR"; $data = file_get_contents("https://finance.google.com/bctzjpnsun/converter?a=$amount&from=$from&to=$to"); preg_match("/<span class=bld&g
$amount="10";
$from="USD";
$to="INR";
$data = file_get_contents("https://finance.google.com/bctzjpnsun/converter?a=$amount&from=$from&to=$to");
preg_match("/<span class=bld>(.*)<\/span>/",$data, $converted);
$converted = preg_replace("/[^0-9.]/", "", $converted[1]);
echo number_format(round($converted, 3),2); exit;
$amount=“10”;
$from=“USD”;
$to=“印度卢比”;
$data=文件\u获取\u内容(“https://finance.google.com/bctzjpnsun/converter?a=$amount&from=$from&to=$to”);
预匹配(“/(.*)/”,$data,$converted);
$converted=preg_replace(“/[^0-9.]/”,“,$converted[1]);
回波号_格式(圆形($converted,3),2);出口;
我得到的结果是0.00
除此之外还有其他方法吗
$amount="10";
$from="USD";
$to="INR";
$url = file_get_contents('https://free.currencyconverterapi.com/api/v5/convert?q=' . $from . '_' . $to . '&compact=ultra');
$json = json_decode($url, true);
$rate = implode(" ",$json);
$total = $rate * $amount;
$rounded = round($total);
return $rounded;
使用此代码
使用此代码谷歌的URL不再工作谷歌的URL不再工作