title: Codeigniter / MVC way of calling a rest api
body: <p>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.</p>
  
  <p>I have a controller called <code>objects</code> and lets say it will have a method called <code>getallobjects</code>. This method actually has to return data from the widget application.</p>
  
  <p>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:</p>
  
  <pre><code>   http://myserver/widget/abc.php?method=getsomething
  </code></pre>
  
  <p>This returns a bunch of json encoded data.</p>
  
  <p>How would I use this type of an API in my MVC CI app?</p>
  
  <p>So far, this is what my controller looks like:</p>
  
  <pre><code> class Objects extends CI_Controller {
       public function __construct()
       {
           parent::__construct();
           $this-&gt;load-&gt;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-&gt;load-&gt;view('includes/template', $data);
       }
    }  
  </code></pre>