我正在使用谷歌货币转换器API,我不知道由于某些原因它显示我所有的值0.它有时工作,但大多数它显示0作为值,无法理清谷歌的API是否已关闭或出现问题在我的代码中。
$final_rateUSD = // Current USD value + our commission
$rateWithcommsellvalue = // Current USD value + our commission
$final_rateAUD = get_currency('USD', 'AUD', $final_rateUSD);
$final_rateSellAUD = get_currency('USD', 'AUD', $rateWithcommsellvalue);
function get_currency($from_Currency, $to_Currency, $rate) {
$amount = urlencode($rate);
$from_Currency = urlencode($from_Currency);
$to_Currency = urlencode($to_Currency);
$get = file_get_contents("https://www.google.com/finance/converter?a=$amount&from=$from_Currency&to=$to_Currency");
$get = explode("<span class=bld>", $get);
$get = explode("</span>", $get[1]);
$converted_amount = preg_replace("/[^0-9\.]/", null, $get[0]);
return round($converted_amount, 5);
}