title: Facebook Signed in request / fangate not working. Undefined index/offset errors
body: <p>I'm creating a facebook tab page and I would like to use fan gating.</p>
  
  <p>I've used fan gating before and have had no problems, but this was like 4 months ago. And I'm using the same PHP but this time I'm getting problems.</p>
  
  <p>See below the basic code for my app and the fan gate conditional statement...</p>
  
  <p>But I get this error for some reason...</p>
  
  <p><strong>Notice: Undefined index: signed_request in /home/sites/example.co.uk/www/competition/index.php on line 126
  Notice: Undefined offset: 1 in /home/sites/example.co.uk/www/competition/index.php on line 128
  Like</strong></p>
  
  <p><br /></p>
  
  <p>Weird..</p>
  
  <p>I've never had problems with using this before, has facebook changed the way this works?</p>
  
  <p>Any help would be much a appreciated thanks.</p>
  
  <p><br /></p>
  
  <pre><code>&lt;?php
  
  $fb_app_id   = '000000000000000';           
  $fb_secret   = '00000000000000000000000000000000';
  $fb_app_url  = 'http://example.co.uk/competition';  
  $fb_tab_url  = 'http://www.facebook.com/example/app_000000000000000';
  $fb_channel  = '//example.co.uk'
  
  require 'src/facebook.php';
  
  //Create facebook application instance.
  $facebook = new Facebook(array(
    'appId'  =&gt; $fb_app_id,
    'secret' =&gt; $fb_secret,
    'cookie' =&gt; true,
  ));
  
  ?&gt;
  
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  
      &lt;meta property="fb:app_id" content="&lt;?php echo $fb_app_id ?&gt;" /&gt;
  
  &lt;/head&gt;
  
  &lt;body&gt;
  
      &lt;div id="fan-gate"&gt;
  
          &lt;?php
  
              $signed_request = $_REQUEST["signed_request"];
  
              list($encoded_sig, $payload) = explode('.', $signed_request, 2);
  
              $data = json_decode(base64_decode(strtr($payload, '-_', '+/')), true);
  
              if (empty($data["page"]["liked"])) {
  
          ?&gt;
  
              LIKE US...      
  
          &lt;?php } else { ?&gt;
  
              &lt;strong&gt;YOU'VE LIKED OUR PAGE, THANKS!!!&lt;/strong&gt;
  
          &lt;?php } ?&gt;
  
      &lt;/div&gt;
  
      &lt;div id="fb-root"&gt;&lt;/div&gt;
  
      &lt;script&gt;
  
          window.fbAsyncInit = function() {
              FB.init({
                  appId: '&lt;?php echo $fb_app_id ?&gt;',
                  channelUrl : '&lt;?php echo $fb_channel ?&gt;/channel.html', // Channel File
                  cookie: true,
                  xfbml: true,
                  oauth: true,
                  status: true
              });
              FB.Canvas.setAutoGrow(true);
          };
  
      &lt;/script&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><br /></p>
  
  <p>Also tried this, but it always just says the second condition, even tho I haven't like the page.</p>
  
  <pre><code>&lt;?php
  
  $fb_app_id   = '000000000000000';           
  $fb_secret   = '00000000000000000000000000000000';
  $fb_app_url  = 'http://example.co.uk/competition';  
  $fb_tab_url  = 'http://www.facebook.com/example/app_000000000000000';
  $fb_channel  = '//example.co.uk'
  
  require 'src/facebook.php';
  
  //Create facebook application instance.
  $facebook = new Facebook(array(
    'appId'  =&gt; $fb_app_id,
    'secret' =&gt; $fb_secret,
    'cookie' =&gt; true,
  ));
  
  ?&gt;
  
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  
      &lt;meta property="fb:app_id" content="&lt;?php echo $fb_app_id ?&gt;" /&gt;
  
  &lt;/head&gt;
  
  &lt;body&gt;
  
      &lt;div id="fan-gate"&gt;
  
          &lt;?php
  
          $signed_request = $facebook-&gt;getSignedRequest();
  
          $like_status = $signed_request["page"]["liked"];
  
          if($like_status){
  
              echo 'LIKE US...';
  
          } else {
  
              echo '&lt;strong&gt;YOU'VE LIKED OUR PAGE, THANKS!!!&lt;/strong&gt;';
  
          }
  
      ?&gt;
  
      &lt;/div&gt;
  
      &lt;div id="fb-root"&gt;&lt;/div&gt;
  
      &lt;script&gt;
  
          window.fbAsyncInit = function() {
              FB.init({
                  appId: '&lt;?php echo $fb_app_id ?&gt;',
                  channelUrl : '&lt;?php echo $fb_channel ?&gt;/channel.html', // Channel File
                  cookie: true,
                  xfbml: true,
                  oauth: true,
                  status: true
              });
              FB.Canvas.setAutoGrow(true);
          };
  
      &lt;/script&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>