-1

I want to take the values from the URL and perform a currency conversion based on them. EG-

I want to receive URL's as:

http://www.mysite.com/conv/?amnt=7.15&from=GBP&to=USD

The returned results will then be in XML format.

My question is - how can I read those values, check for particular errors, perform the convert function and finally output the XML response using a RESTful interface?

Obviously, I'm not looking for the code to be written for me, I just need the logic explained to me and how can I can go about building this (I'm very new to this so forgive the vagueness)

Any help is much appreciated! Thanks

tctc91
  • 1,343
  • 2
  • 21
  • 41

2 Answers2

1

Learn about:

Community
  • 1
  • 1
Ayman Safadi
  • 11,502
  • 1
  • 27
  • 41
0

After much research and many questions I've nearly finished building this :)

Here's how I did it in pseudo-code:

1) URL is called
    - Check for request type (get/put etc)
    - Add the get values to PHP variables
    - Check for errors in the GET call (if error, load error from our pre-defined errors file and build XML page + change content type)
    - If all is good - load the currency converson function
2) Call conversion function
    - Load currency rates from XML file in Cache
    - Check currency timestamp (If older than 2 hours, re-import from web with fallback options).
    - Perform conversion using the available variables
    - Build XML response and output to page.
tctc91
  • 1,343
  • 2
  • 21
  • 41