Creating An Api
Posted 11 January 2013 - 01:18 PM
I'm developing an API. The API will receive and send XML. The message types and how to respond are defined by a value inside the XML. So, when I receive an XML post, I will parse through the XML, and find the appropriate response.
I would like to set up the API so that the clients only need to post to one page. (i.e. example.com/api/). My system will then determine the type of XML request, and respond appropriately.
My question is, (I'm new to MVC, so please excuse the ignorance), would I just route every request to one controller that will interpret the XML and then execute the appropriate code? If so, how do I adjust the urlManager to route all post requests to the ApiController class? Or would I use a routes.php for this?
Let me know if this doesn't make sense and I will try and clarify. Thanks in advance.
Posted 11 January 2013 - 01:36 PM
Actually, Yii automatically uses default url as index.php?r=api (in your current case) and index.php?r=api/getpost in case you have an action getPost in api controller.
Posted 11 January 2013 - 02:50 PM
A little more info about the MVC design pattern can be found here: http://www.yiiframew...1/en/basics.mvc
You can set more friendly URL's in config/main.php like PeRoChAk sais, more info about that can be found here: