title: Retrieving menu information from mmjmenu api to deliver to my website
body: <p>I am new to working with api and have been searching for the little tiny piece of code that makes the following snippit possible, but I am having trouble finding it. I have been watching tutorials on jquery, ajax, json, and php but have not found exactly what I need. If someone could show me a simple example of how the request would be constructed from the opening tag of the file to the closing tag it would be very helpful. After I get the data returned I can figure out how to parse and style it for display.
  The first piece of code is the example that someone else said they use but I tried it (with my own api key) and I seem to be missing something. The second code is the "Mmjmenu.php" file that I assume needs to be in the same directory as the first php file. Following the code is the error I get.
  ("my api key" is replacing my actual key)</p>
  
  <pre><code>&lt;?php
  require 'API/Mmjmenu.php';
  $client = new Mmjmenu('my api key');
  
  $menuItems      = $client-&gt;menuItems();
  $menuItems      = json_decode($menuItems, true);
  
  foreach($menuItems['menu_items'] as $item)
  {
      echo $item['name'];
  }
  ?&gt;
  </code></pre>
  
  <p><strong>This is the "Mmjmenu.php" file (can be found on git hub):</strong></p>
  
  <pre><code>&lt;?php
  
  
  class Mmjmenu {
      private $domain = 'https://mmjmenu.com/api/v1';
  
      private $active_api_key;
      private $active_domain;
  
      private $username;
      private $password;
  
      public function __construct($api_key, $active_domain = null, $active_api_key = null) {
          $this-&gt;setActiveDomain($this-&gt;domain, $api_key);
      }
  
      public function setActiveDomain($active_domain, $active_api_key) {
          $this-&gt;active_domain = $active_domain;
          $this-&gt;active_api_key = $active_api_key;
          $this-&gt;username = $this-&gt;active_api_key;
          $this-&gt;password = 'x';
      }
  
      private function sendRequest($uri, $method = 'GET', $data = '') {
          $ch = curl_init();
  
          curl_setopt($ch, CURLOPT_URL, "https://mmjmenu.com/api/v1" . $uri);
          curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
          curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
          curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
          curl_setopt($ch, CURLOPT_MAXREDIRS, 1);
          curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
          curl_setopt($ch, CURLOPT_HTTPHEADER, array(
              'Content-Type: application/json',
              'Accept: application/json'
          ));
  
          curl_setopt($ch, CURLOPT_USERPWD, $this-&gt;username . ':' . $this-&gt;password);
  
          $method = strtoupper($method);
          if($method == 'POST')
          {
              curl_setopt($ch, CURLOPT_POST, true);
              curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
          }
          else if ($method == 'PUT')
          {
              curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
              curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
          }
          else if($method != 'GET')
          {
              curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
          }
  
          curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
          curl_setopt($ch, CURLOPT_TIMEOUT, 30);
  
          $result = new StdClass();
          $result-&gt;response = curl_exec($ch);
          $result-&gt;code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
          $result-&gt;meta = curl_getinfo($ch);
  
          $curl_error = ($result-&gt;code &gt; 0 ? null : curl_error($ch) . ' (' . curl_errno($ch) . ')');
  
          curl_close($ch);
  
          if ($curl_error) {
              //print('ERROR');
          }
  
          return $result;
      }
  
      /****************************************************
      ********************* MENU ITEMS ********************
      ****************************************************/
  
      public function menuItems() {
          $base_url = '/menu_items';
          $menuItems = $this-&gt;sendRequest($base_url);
          return $menuItems-&gt;response;
      }
  
      public function menuItem($id) {
          $base_url = "/menu_items/$id";
          $menuItem = $this-&gt;sendRequest($base_url);
          return $menuItem-&gt;response;
      }
  }
  ?&gt;
  </code></pre>
  
  <p><strong>This is the error I get when executing the first file:</strong>
  Fatal error: Class 'Mmjmenu' not found in /home/...(my directory).../mmtest.php on line 4</p>