title: API integration in Codeigniter application
body: <p>I'm trying to integrate API from <code>MyOperator</code>, in my <code>CRM</code> project, which is developed in <code>CodeIgniter</code>. For that they provide me some code, but when I tried to use that code in my application, it give me <code>JSON</code> data with </p>
  
  <blockquote>
    <p>404 page not found error</p>
  </blockquote>
  
  <p>Here is the code that they provided :</p>
  
  <pre><code>&lt;?php                                                                                   
  
  /**
   * @description : Library to access MyOperator Public API
   */
  Class Myoperator {
  
      protected $developers_url = 'https://developers.myoperator.co/';
      protected $token = 'XXXXXXXXX';
  
      function __construct() {
  
      }
  
      public function run() {
          # request for Logs
          $url = $this-&gt;developers_url . 'search';
          $fields = array("token" =&gt; $this-&gt;token);
          $result = $this-&gt;_post_api($fields, $url);
  
          $this-&gt;log("result");
          $this-&gt;log($result);
      }
  
      private function _post_api(Array $fields, $url) {
          try {
              $ch = curl_init();
              curl_setopt($ch, CURLOPT_URL, $url);
              curl_setopt($ch, CURLOPT_TIMEOUT, 30);
              curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
              curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
              curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
              $result = curl_exec($ch);
          } catch (Exception $e) {
              return false;
          }
          $this-&gt;log("url");
          $this-&gt;log($url);
          $this-&gt;log("fields");
          $this-&gt;log($fields);
          curl_close($ch);
          if ($result)
              return $result;
          else
              return false;
      }
  
      private function log($message) {
          print_r($message);
          echo "\n";
      }
  
  }
  
  
  $Class = new Myoperator();
  $Class-&gt;run();
  </code></pre>
  
  <p>This code gives me desired output if I run this code directly, but I'm confuse that where to use this code, which part is in controller and which part is in view in <code>CodeIgniter</code>. Any kind of help is welcome, thanks in advance. </p>