Ok, I know this may seem like a question with many different answers, but I want to get some idea as to how to proceed.
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.
I think you should create a API controller with different actions for the different type of API requests (i.e. post/update/delete etc.). So your client can send a post request to index.php?r=api/post (or api/post), where ‘api’ is your controller. You process all data in the ‘post’ action and give back a proper response (in any format you want off course).