【问题标题】:currency convert function based on URL $_GET variables基于 URL $_GET 变量的货币转换函数
【发布时间】:2011-12-30 18:33:48
【问题描述】:

我想从 URL 中获取值并根据它们执行货币转换。 EG-

我想接收网址为:

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

返回的结果将采用 XML 格式。

我的问题是 - 我如何读取这些值、检查特定错误、执行转换功能并最终使用 RESTful 接口输出 XML 响应?

显然,我不是在寻找要为我编写的代码,我只需要向我解释逻辑以及如何构建它(我对此很陌生,所以请原谅含糊不清)

非常感谢任何帮助!谢谢

【问题讨论】:

  • 您的问题到底是什么?这在寻找答案时可能会有所帮助。

标签: php rest get


【解决方案1】:
【解决方案2】:

经过大量研究和许多问题,我几乎完成了这个:)

这是我在伪代码中的做法:

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.

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-12
    • 1970-01-01
    • 1970-01-01
    • 2017-06-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多