title: Issue reading HTTP request body from a JSON POST in PHP
body: <p>I'm writing a script that is registered as an endpoint for a webhook. I know that it's successfully registered because I'm writing the header of every request to my server logs. Here's a sample:</p>
  
  <pre><code>Content-Type: text/xml; charset=UTF-8
  User-Agent: Jakarta Commons-HttpClient/3.1
  Host: =={obfuscated}== 
  Content-Length: 1918
  </code></pre>
  
  <p>The API that I've registered with is POST-ing a JSON object to my script, and I'd like to parse that object using PHP. As you can see from the request header, there's a nice big fat JSON object waiting to be parsed. It seems straightforward, but it hasn't been. </p>
  
  <p>At first I tried using <code>$_POST['json']</code> or just <code>$_POST</code> but since the data isn't in an array, I wasn't really sure how to access it like that.</p>
  
  <p>I've tried using <code>file_get_contents('php://input')</code> and <code>fopen('php://input', 'r')</code> with and without <code>json_decode()</code> but no luck. I can't use <code>http_get_request_body()</code> since the server I'm on doesn't have PECL and that's out of my control.</p>
  
  <p>Are there any other ways to interact with the POST-ed JSON object that I'm missing? Thanks!</p>