title: how to read facebook signed_request to get user_id
body: <p>According to <a href="https://developers.facebook.com/docs/authentication/canvas/" rel="noreferrer">Facebook - Authentication within a Canvas Page Document</a>, they say that we will be getting a <code>signed_request</code> which consists a JSON object. Now they say that <code>signed_request</code> can be get through <code>$_POST['signed_request']</code> I agree its working for me. </p>
  
  <p>Now according to them if the user is logged in i will be getting a JSON object value like this:-</p>
  
  <pre><code>{
    "expires":UNIXTIME_WHEN_ACCESS_TOKEN_EXPIRES,
    "algorithm":"HMAC-SHA256",
    "issued_at":UNIXTIME_WHEN_REQUEST_WAS_ISSUED,
    "oauth_token":"USER_ACCESS_TOKEN",
    "user_id":"USER_ID",
    "user":{
      "country":"ISO_COUNTRY_CODE",
      "locale":"ISO_LOCALE_CODE",
      ...
    }
  }
  </code></pre>
  
  <p>Now i want to fetch the <code>user_id</code> out of this so i am using this piece of code but its not working:-</p>
  
  <pre><code>if(isset($_POST['signed_request']))
  {
      echo 'YES';
      $json = $_POST['signed_request'];
      $obj = json_decode($json);
      print $obj-&gt;{'user_id'};    
  }
  </code></pre>
  
  <p>It just print the <code>YES</code>. Why is it so?</p>
  
  <p>I have read somewhere that without app authentication i will not be able to extract the <code>user_id</code> but according to the facebook, this is the 1st step and authenticating the application would be 4th. I am new to it, if somebody can please help me, it will be of great help. Thanks.</p>