Crazy Horse
asked on
where to put api in mvc structure and how to call it
I want to use an API in my mvc project but am not sure where to put it or how to access it.
My current structure in the root has 2 folders with subfolders like:
App
config
controllers
libraries
views
models
public
css
js
img
The API has a root folder and api folder inside:
SomeAPI
api
So, where would the correct place be to put the SomeAPI folder in relation to my structure and how can I call it?
The api documentation say I am meant to do this:
but this assumes that I am putting the SomeAPI in my root directory, not using MVC.
Any help would be much appreciated. I have tried all different directories but nothing works.
My current structure in the root has 2 folders with subfolders like:
App
config
controllers
libraries
views
models
public
css
js
img
The API has a root folder and api folder inside:
SomeAPI
api
So, where would the correct place be to put the SomeAPI folder in relation to my structure and how can I call it?
The api documentation say I am meant to do this:
data-api="/SomeAPI/api/"
but this assumes that I am putting the SomeAPI in my root directory, not using MVC.
Any help would be much appreciated. I have tried all different directories but nothing works.
I would create a model class for the api, with one of the properties being the api url. Then, your methods that relate to the api would be inside the class, and you would instantiate an instance of the api from the controller, and call your methods, etc from there.
ASKER
Hmm. I am a bit confused now. I only use my model for database related stuff and this has nothing to do with a database. Could I put it in my controller? It is an API that gets instagram images and displays them in a grid.
So, in a non-MVC world, you would just put this wherever you want it to show up:
And where in the folder structure would I put the folder for the API?
So, in a non-MVC world, you would just put this wherever you want it to show up:
<div data-il
data-il-api="/someAPI/api/"
data-il-username="myInstagramAccount"
data-il-hashtag=""
data-il-lang="en"
data-il-show-heading="true"
data-il-scroll="true"
data-il-width="270px"
data-il-height="350px"
data-il-image-size="medium"
data-il-bg-color="#285989"
data-il-content-bg-color="#F8F8F8"
data-il-font-color="#FFFFFF"
data-il-ban="">
</div>
And where in the folder structure would I put the folder for the API?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.