kam_uoc Posted January 27, 2009 Share Posted January 27, 2009 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 More sharing options...
MadTechie Posted January 27, 2009 Share Posted January 27, 2009 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) Link to comment https://forums.phpfreaks.com/topic/142594-solved-php-and-web-services/#findComment-747457 Share on other sites More sharing options...
kam_uoc Posted January 27, 2009 Author Share Posted January 27, 2009 Thanks man. Its works perfectly. thanks again. Link to comment https://forums.phpfreaks.com/topic/142594-solved-php-and-web-services/#findComment-747806 Share on other sites More sharing options...
MadTechie Posted January 27, 2009 Share Posted January 27, 2009 Cool Can you click solved please Link to comment https://forums.phpfreaks.com/topic/142594-solved-php-and-web-services/#findComment-747819 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.