Example #1
0
 /**
  * Return conversion rate between given currencies
  *
  * @param string $from Current currency code
  * @param string $to Desired currency code
  *
  * @return double Converted value
  * @throws \Exception
  */
 public function getConversionRate($from, $to)
 {
     $data = array(self::CURRENCY_CONVERTOR_PARAM_FROM_CURRENCY => $from, self::CURRENCY_CONVERTOR_PARAM_TO_CURRENCY => $to);
     try {
         $client = new \SoapClient(self::CURRENCY_CONVERTOR_SOAP_LOCATION);
         return $client->ConversionRate($data)->ConversionRateResult;
     } catch (\SoapFault $e) {
         throw new \Exception('Error retreiving data from the remote server.');
     }
 }
 public static function getRate($from, $to)
 {
     $client = new \SoapClient('http://www.webservicex.net/CurrencyConvertor.asmx?WSDL');
     try {
         $params['FromCurrency'] = strtoupper($from);
         $params['ToCurrency'] = strtoupper($to);
         $rate = $client->ConversionRate($params);
         return $rate->ConversionRateResult;
     } catch (Exception $e) {
         echo "Exception: " . nl2br($e) . "\n<br/>";
         return false;
     }
 }
Example #3
0
				<label>Konvertuj iz:</label>
				<input type="text" name="iz"><br><br>
				<label style="padding-right:3px">Konvertuj u:</label>
				<input type="text" name="u"><br><br>
				<input type="submit" value="Konvertuj">
			</form>
		</div>
		<?php 
if ($_POST) {
    if (isset($_POST['iz']) && isset($_POST['u'])) {
        $iz = $_POST['iz'];
        $u = $_POST['u'];
        $params = array("FromCurrency" => $iz, "ToCurrency" => $u);
        $soap = "http://www.webservicex.net/CurrencyConvertor.asmx?WSDL";
        $client = new SoapClient($soap, array('trace' => true));
        $result = $client->ConversionRate($params);
        echo "<div class='forma-konv'>\n\t\t\t\t\t\t\t<p> Vrijednost konverzije: " . $result->ConversionRateResult . "</p>\n\t\t\t\t\t\t  </div>";
        echo "REQUEST:\n" . htmlentities($client->__getLastRequest()) . "\n";
        echo "RESPONSE:\n" . htmlentities($client->__getLastResponse()) . "\n";
        //$soap = simplexml_load_string($client->__getLastRequest());
        //echo "EVO OVO: ".$soap;
        $soap = simplexml_load_string($client->__getLastRequest());
        $response = $soap->children('http://schemas.xmlsoap.org/soap/envelope/')->Body->children()->CreateRebillCustomerResponse;
        $customerId = (string) $response->ConversionRateResult;
        echo $customerId;
    }
}
?>
		<br><br><br>
		<div class="col1">
			AFA-Afghanistan Afghani<br>