【问题标题】:Web Service, webservicex currency converter phpWeb Service, webservicex 货币转换器 php
【发布时间】:2014-07-02 04:59:49
【问题描述】:

我正在尝试使用http://www.webservicex.com/CurrencyConvertor.asmx?WSDL 的网络服务。 我可以在输入两种货币时转换金额,即“NZD”“GBP”等。但我需要有两个下拉框来获取所有货币代码并将它们作为选项放入。我不知道如何获得这些货币代码。谢谢你

php 的代码是

/* Get the values for the amount and currencies */
$amount = $_POST['amount'];
$currency1 = $_POST['currency1'];
$currency2 = $_POST['currency2'];

// Set the url for the webservice.
$wsdl="http://www.webservicex.com/CurrencyConvertor.asmx?WSDL";

// Make soap client.
$client = new SoapClient( $wsdl );

// Set up the parameters
$country=array();

// Set the country variable to the country codes.
$country['FromCurrency']= $currency1;
$country['ToCurrency'] = $currency2;

// Use the client to run the required operation and receive a response
$result = $client->ConversionRate($country);


// Print the results.
print("<br /> The exchange rate from <b>".$country['FromCurrency']."</b> to    <b>".$country['ToCurrency']."</b> is: <b>". $result->ConversionRateResult)."</b><br />";
}
?>

在 html 中,我有两个选择框,我需要用国家代码(“NZD”、“GBP”等)填充它们,它们将是 currency1 和 currency2 变量。我想从 webservicex 获取这些货币代码作为数组或我可以用来填充选择框的东西。

【问题讨论】:

  • 分享您的代码到目前为止,您需要国家代码或货币代码吗?
  • -1 不是一个真正的问题。 Learn how to ask

标签: php converter currency


【解决方案1】:

你可以使用这个库https://github.com/florianv/swap。它支持多个提供者,并会为您节省低级的东西。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多