We have a web app (let's call it widget app) that contains data I need to integrate with a new Codeigniter app that I’m building.
I have a controller called objects and lets say it will have a method called getallobjects. This method actually has to return data from the widget application.
There is an “API” of sorts for the widget app, but the way that I call it in a RESTful way by getting a URL like:
http://myserver/widget/abc.php?method=getsomething
This returns a bunch of json encoded data.
How would I use this type of an API in my MVC CI app?
So far, this is what my controller looks like:
class Objects extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->load->helper('url');
}
public function getallobjects()
{
$data['objectlist'] = ????/* This is where I need to call the rest api and get json data. */
$data['main_content']='objects';
$this->load->view('includes/template', $data);
}
}