title: Accessing Variables in Raw PHP POST Data
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/4035742/parse-json-in-php">Parse Json in php</a>  </p>
  </blockquote>
  
  
  
  <p>I am working with an API that sends a POST request to my PHP script when a user performs an action. I can easily log the raw POST data to a file, for example:</p>
  
  <pre><code>$rawPostData = file_get_contents('php://input');
  $all = date("F j, Y, g:i a") . " " . $rawPostData . "\r\n";
  file_put_contents("Activity.log", $all, FILE_APPEND);
  </code></pre>
  
  <p>Writes this to the log file:</p>
  
  <pre><code>October 1, 2012, 12:34 pm [{"changed_aspect": "media", "subscription_id": 2421759, "object": "user", "object_id": "931456", "time": 1349120084}]
  </code></pre>
  
  <p>The only thing I am interested in is the object_id value. How can I access this value in the raw POST data? I've tried a ton and searched a number of forums for a solution. It seems simple enough but I can't seem to get it. Any ideas?</p>