how do I organize API stuff |
I'm building an app with CI that relies a lot on returned data from multiple APIs. For example APIs from FlightAware, WeatherUndergound, amongst others. They'll be SOAP, RESTful, JSON, etc. based. I imagine it's best to not have the code snippets for those APIs in controller or view - what's best practice for integrating APIs, in general, into CI's structure considering they'll be called both on demand and in the background?
P.S. - I'll be displaying the returned data straight to a page and in some cases storing them to the database (temporarily, of course).
I am not sure about best practice, but I would put the code for each API into a library, which you can then use in any way you want. However when the API changes, you need only update the one library file.
Hope that helps, Paul.
Question is to general, needs a book to answer it; Here is one good: "building apis you won't hate"
|
Welcome Guest, Not a member yet? Register Sign In |