Search:
Main Menu
Login | RSS |

Quick PHP Code Tips and Examples

PHP Programming Tips, Tutorials and Source Code Examples for newbie

PHP: Currency Exchange using XML-RPC client

May 11th, 2007 by Jon Moffet

This is an example PHP code I wrote to demonstrate how to connect to Foxrate Currency Exchange server and retrieve the latest exchange rate.

The example uses The Incutio XML-RPC for PHP library. Please visit refer to Incutio XML-RPC Library Manual for further in-depth reference.

PHP:
  1. require('IXR.inc.php');
  2.  
  3. // connect to foxrate.org currency exchange server
  4. $client = new IXR_Client('http://foxrate.org/rpc/');
  5.  
  6. //make the currency exchange
  7. if (!$client->query('foxrate.currencyConvert', 'USD', 'GBP',1000)) {
  8.     die('Error detected - '.$client->getErrorCode().' : '.$client->getErrorMessage());
  9. }
  10.  
  11. $response = $client->getResponse();
  12. echo "USD1000  is currently equal to GBP " . $response['amount'];

The demo shows you how to get the current value of USD 1000 in British Pound (GBP). Hopefully this example will be useful for you to build a working currency exchage webapp using foxrate.org api

Download the sample code here : foxrate_rpc_1.zip

Tags: , , , , , ,

Bookmark Post:These icons link to social bookmarking sites where readers can share and discover new web pages.
  • NewsVine
  • Reddit
  • Netvouz
  • Spurl
  • Furl
  • digg
  • YahooMyWeb
  • del.icio.us

Posted in Uncategorized | No Comments »

Related Posts

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.