Jump to content

Recommended Posts

Hi all,

I want to know how to work with web services in php.

I just want to convert currencies to USD to Rupee. I have found a web site which offers conversion as web service.

http://www.webservicex.net/CurrencyConvertor.asmx?op=ConversionRate

 

I have no clue how to connect this to my site. I haven't any knowledge on web services and php.

Any tutorial???

Thanks in advance.

 

Link to comment
https://forums.phpfreaks.com/topic/142594-solved-php-and-web-services/
Share on other sites

Here is an untested example

I hope it make sense or at least gives you an idea on how it works

 

<?php
//FROM TO CODE = http://www.webservicex.net/CurrencyConvertor.asmx?op=ConversionRate
//GET XML = http://www.webservicex.net/CurrencyConvertor.asmx/ConversionRate?FromCurrency=USD&ToCurrency=GBP

$From="USD";
$To="GBP";
$URL = "http://www.webservicex.net/CurrencyConvertor.asmx/ConversionRate?FromCurrency=$From&ToCurrency=$To";

//XML
$xml  = new SimpleXMLElement($URL);
$Rate  = $xml->double;


//OR use 
/*
$Rate = file_get_contents($URL);
if (preg_match('/<.*?>([^<]*)/', $Rate, $regs))
{
$Rate= $regs[1];
}
*/
echo $Rate;

?>

 

 

Now using XML you could get all the details for conversion from the remote site (http://www.webservicex.net/CurrencyConvertor.asmx?WSDL)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.