title: Consuming a JSON API with PHP
body: <p>I am trying to consume a JSON API with PHP. </p>
  
  <p>I have tried using CURL to get a response:</p>
  
  <pre><code>curl 'http://104.239.130.176:3000/api/users/authenticate?email=my_username_here&amp;password=my_password'
  </code></pre>
  
  <p>This doesn't give me any response in the terminal.</p>
  
  <p>I have also tried swapping email for username: </p>
  
  <pre><code>curl 'http://104.239.130.176:3000/api/users/authenticate?username=my_username_here&amp;password=my_password'
  </code></pre>
  
  <p>I have written the following in a PHP file but this gives me a 404 error in the browser.</p>
  
  <pre><code>&lt;?php   
    // Parameters
    $tpm_base_url = 'http://104.239.176.130:3000/'; // ending with /
    $req_uri = 'api/users/authenticate'; // GET /passwords.json
    $username = 'my_username';
    $password = 'my_password';
  
    // Request headers
    $headers = array( 
      'Content-Type: application/json; charset=utf-8'
    );
  
    // Request
    $ch = curl_init($tpm_base_url . $req_uri);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($ch, CURLOPT_HEADER, TRUE); // Includes the header in the output
    curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password); // HTTP Basic Authentication
    $result = curl_exec($ch); 
    $status = curl_getinfo($ch, CURLINFO_HTTP_CODE);  
    curl_close($ch);
  
    // Get headers and body
    list($headers, $body) = explode("\r\n\r\n", $result, 2);
    $arr_headers = explode("\r\n", $headers);
    $arr_body = json_decode($body, TRUE);
  
    // Show status and array of passwords
    echo 'Status: ' . $status . '&lt;br/&gt;';
    print_r($arr_body);
  </code></pre>
  
  <p>I am not sure where I am going wrong here. Instructions from the API developer are as follows: </p>
  
  <p>The API has a basic JWT security so first request token.</p>
  
  <p>POST request to: 
  <a href="http://104.239.176.130:3000/api/users/authenticate" rel="nofollow">http://104.239.176.130:3000/api/users/authenticate</a></p>