title: App works only for but not for other users
body: <p>I am editing the default app provided by the heroku. This works with my login. But other users doesn't see app working. My app requires permission - user_relationships, friends_relationships. </p>
  
  <p>When I debug the access_token seen by the user, it correctly specifies the above permissions.</p>
  
  <p>Somebody can please point me what is the issue?? Thanks in advance.</p>
  
  <pre><code>&lt;?php
  
  // Provides access to app specific values such as your app id and app secret.
  // Defined in 'AppInfo.php'
  require_once('AppInfo.php');
  
  // Enforce https on production
  if (substr(AppInfo::getUrl(), 0, 8) != 'https://' &amp;&amp; $_SERVER['REMOTE_ADDR'] != '127.0.0.1') {
  header('Location: https://'. $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
  exit();
  }
  
  // This provides access to helper functions defined in 'utils.php'
  require_once('utils.php');
  
  
   /****************************************************************************
   *
   * The content below provides examples of how to fetch Facebook data using the
  * Graph API and FQL.  It uses the helper functions defined in 'utils.php' to
  * do so.  You should change this section so that it prepares all of the
  * information that you want to display to the user.
  *
   ****************************************************************************/
  
   require_once('sdk/src/facebook.php');
  
  // Instantiating Facebook object to access SDK
  $facebook = new Facebook(array(
  'appId'  =&gt; AppInfo::appID(),
  'secret' =&gt; AppInfo::appSecret(),
  ));
  
  // Returns facebook user id of the current user
  $user_id = $facebook-&gt;getUser();
  if ($user_id) {
  try {
    // Fetch the viewer's basic information
    $basic = $facebook-&gt;api('/me');
  } catch (FacebookApiException $e) {
  // If the call fails we check if we still have a user. The user will be
  // cleared if the error is because of an invalid accesstoken
  if (!$facebook-&gt;getUser()) {
    header('Location: '. AppInfo::getUrl($_SERVER['REQUEST_URI']));
    exit();
  }
  }
  
  $access_token = $facebook-&gt;getAccessToken();
  echo $access_token;
  // Here is an example of a FQL call that fetches all of your friends that are
  // using this app
  $app_using_friends = $facebook-&gt;api(array(
   'method' =&gt; 'fql.query',
   'query' =&gt; 'SELECT uid, name, relationship_status FROM user WHERE uid IN(SELECT uid2  FROM friend WHERE uid1 = me())'
  ));
  
  }
  
  // Fetch the basic info of the app that they are using
  $app_info = $facebook-&gt;api('/'. AppInfo::appID());
  
  $app_name = idx($app_info, 'name', '');
  
  ?&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html xmlns:fb="http://ogp.me/ns/fb#" lang="en"&gt;
  &lt;head&gt;
  &lt;meta charset="utf-8" /&gt;
  &lt;meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=2.0, user-scalable=yes" /&gt;
  
  &lt;title&gt;&lt;?php echo he($app_name); ?&gt;&lt;/title&gt;
  &lt;link rel="stylesheet" href="stylesheets/screen.css" media="Screen" type="text/css" /&gt;
  &lt;link rel="stylesheet" href="stylesheets/mobile.css" media="handheld, only screen and (max-width: 480px), only screen and (max-device-width: 480px)" type="text/css" /&gt;
  
  &lt;!--[if IEMobile]&gt;
  &lt;link rel="stylesheet" href="mobile.css" media="screen" type="text/css"  /&gt;
  &lt;![endif]--&gt;
  
  &lt;!-- These are Open Graph tags.  They add meta data to your  --&gt;
  &lt;!-- site that facebook uses when your content is shared     --&gt;
  &lt;!-- over facebook.  You should fill these tags in with      --&gt;
  &lt;!-- your data.  To learn more about Open Graph, visit       --&gt;
  &lt;!-- 'https://developers.facebook.com/docs/opengraph/'       --&gt;
  &lt;meta property="og:title" content="&lt;?php echo he($app_name); ?&gt;" /&gt;
  &lt;meta property="og:type" content="website" /&gt;
  &lt;meta property="og:url" content="&lt;?php echo AppInfo::getUrl(); ?&gt;" /&gt;
  &lt;meta property="og:image" content="&lt;?php echo AppInfo::getUrl('/logo.png'); ?&gt;" /&gt;
  &lt;meta property="og:site_name" content="&lt;?php echo he($app_name); ?&gt;" /&gt;
  &lt;meta property="og:description" content="My first app" /&gt;
  &lt;meta property="fb:app_id" content="&lt;?php echo AppInfo::appID(); ?&gt;" /&gt;
  
  &lt;script type="text/javascript" src="/javascript/jquery-1.7.1.min.js"&gt;&lt;/script&gt;
  
  &lt;script type="text/javascript"&gt;
    function logResponse(response) {
      if (console &amp;&amp; console.log) {
        console.log('The response was', response);
      }
    }
  
    $(function(){
      // Set up so we handle click on the buttons
      $('#postToWall').click(function() {
        FB.ui(
          {
            method : 'feed',
            link   : $(this).attr('data-url')
          },
          function (response) {
            // If response is null the user canceled the dialog
            if (response != null) {
              logResponse(response);
            }
          }
        );
      });
  
      $('#sendToFriends').click(function() {
        FB.ui(
          {
            method : 'send',
            link   : $(this).attr('data-url')
          },
          function (response) {
            // If response is null the user canceled the dialog
            if (response != null) {
              logResponse(response);
            }
          }
        );
      });
  
      $('#sendRequest').click(function() {
        FB.ui(
          {
            method  : 'apprequests',
            message : $(this).attr('data-message')
          },
          function (response) {
            // If response is null the user canceled the dialog
            if (response != null) {
              logResponse(response);
            }
          }
        );
      });
    });
  &lt;/script&gt;
  
  &lt;!--[if IE]&gt;
    &lt;script type="text/javascript"&gt;
      var tags = ['header', 'section'];
      while(tags.length)
        document.createElement(tags.pop());
    &lt;/script&gt;
  &lt;![endif]--&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;div id="fb-root"&gt;&lt;/div&gt;
  &lt;script type="text/javascript"&gt;
    window.fbAsyncInit = function() {
      FB.init({
        appId      : '&lt;?php echo AppInfo::appID(); ?&gt;', // App ID
        channelUrl : '//&lt;?php echo $_SERVER["HTTP_HOST"]; ?&gt;/channel.html', // Channel File
    //oauth        : true,
        status     : true, // check login status
        cookie     : true, // enable cookies to allow the server to access the session
        xfbml      : true // parse XFBML
      });
  
  //FB.login({
      //      scope   : 'user_relationships,friends_relationships'
     //   });
  
      // Listen to the auth.login which will be called when the user logs in
      // using the Login button
      FB.Event.subscribe('auth.login', function(response) {
        // We want to reload the page now so PHP can read the cookie that the
        // Javascript SDK sat. But we don't want to use
        // window.location.reload() because if this is in a canvas there was a
        // post made to this page and a reload will trigger a message to the
        // user asking if they want to send data again.
        window.location = window.location;
      });
  
      FB.Canvas.setAutoGrow();
      };
  
      // Load the SDK Asynchronously
      (function(d, s, id) {
      var js, fjs = d.getElementsByTagName(s)[0];
      if (d.getElementById(id)) return;
      js = d.createElement(s); js.id = id;
      js.src = "//connect.facebook.net/en_US/all.js";
      fjs.parentNode.insertBefore(js, fjs);
      }(document, 'script', 'facebook-jssdk'));
      &lt;/script&gt;
  
     &lt;header class="clearfix"&gt;
     &lt;?php if (isset($basic)) { ?&gt;
     &lt;p id="picture" style="background-image: url(https://graph.facebook.com/&lt;?php echo he($user_id); ?&gt;/picture?type=normal)"&gt;&lt;/p&gt;
  
     &lt;div&gt;
      &lt;h1&gt;Welcome, &lt;strong&gt;&lt;?php echo he(idx($basic, 'name')); ?&gt;&lt;/strong&gt;&lt;/h1&gt;
      &lt;p class="tagline"&gt;
        This is my app. My First Facebook app. 
        &lt;a href="&lt;?php echo he(idx($app_info, 'link'));?&gt;" target="_top"&gt;&lt;?php echo he($app_name); ?&gt;&lt;/a&gt;
      &lt;/p&gt;
  
      &lt;div id="share-app"&gt;
     &lt;/div&gt;
     &lt;?php } else { ?&gt;
     &lt;div&gt;
      &lt;h1&gt;Welcome&lt;/h1&gt;
      &lt;div class="fb-login-button"       data-scope="user_likes,user_photos,user_relationships,friends_relationships"&gt;&lt;/div&gt;
     &lt;/div&gt;
     &lt;?php } ?&gt;
    &lt;/header&gt;
  
    &lt;?php
    if ($user_id) {
    ?&gt;
  
  var $shaheeds = 0;
  var $aazaads  = 0;
  var $confused = 0;
  var $in_trap  = 0;
  var $total    = 0;
  
    &lt;section id="samples" class="clearfix"&gt;
    &lt;h1&gt;Examples of the Facebook Graph API&lt;/h1&gt;
  
    &lt;div class="list"&gt;
      &lt;h3&gt;Shaheed Friends&lt;/h3&gt;
      &lt;ul class="shaheed"&gt;
        &lt;?php
          foreach ($app_using_friends as $friend) {
            // Extract the pieces of info we need from the requests above
            $id = idx($friend, 'uid');
            $name = idx($friend, 'name');
        $r_status = idx($friend, 'relationship_status');
        if($r_status == "Married"){
            $shaheeds++;
        ?&gt;
        &lt;li&gt;
          &lt;a href="https://www.facebook.com/&lt;?php echo he($id); ?&gt;" target="_top"&gt;
            &lt;img src="https://graph.facebook.com/&lt;?php echo he($id) ?&gt;/picture?type=square" alt="&lt;?php echo he($id); ?&gt;"&gt;
            &lt;?php echo he($name); ?&gt;
          &lt;/a&gt;
        &lt;/li&gt;
        &lt;?php
        }
          }
        ?&gt;
      &lt;/ul&gt;
    &lt;/div&gt;
  
    &lt;div class="list inline"&gt;
      &lt;h3&gt;Recent photos&lt;/h3&gt;
      &lt;ul class="photos"&gt;
        &lt;?php
          $i = 0;
          foreach ($photos as $photo) {
            // Extract the pieces of info we need from the requests above
            $id = idx($photo, 'id');
            $picture = idx($photo, 'picture');
            $link = idx($photo, 'link');
  
            $class = ($i++ % 4 === 0) ? 'first-column' : '';
        ?&gt;
        &lt;li style="background-image: url(&lt;?php echo he($picture); ?&gt;);" class="&lt;?php echo $class; ?&gt;"&gt;
          &lt;a href="&lt;?php echo he($link); ?&gt;" target="_top"&gt;&lt;/a&gt;
        &lt;/li&gt;
        &lt;?php
          }
        ?&gt;
      &lt;/ul&gt;
    &lt;/div&gt;
  
    &lt;div class="list"&gt;
      &lt;h3&gt;Friends In Trap&lt;/h3&gt;
      &lt;ul class="in-trap"&gt;
        &lt;?php
          foreach ($app_using_friends as $friend) {
            // Extract the pieces of info we need from the requests above
            $id = idx($friend, 'uid');
            $name = idx($friend, 'name');
        $r_status = idx($friend, 'relationship_status');
        if($r_status == "Engaged" || $r_status == "In a relationship"){
            // This display's the object that the user liked as a link to
            // that object's page.
      $in_trap++;
        ?&gt;
        &lt;li&gt;
          &lt;a href="https://www.facebook.com/&lt;?php echo he($id); ?&gt;" target="_top"&gt;
            &lt;img src="https://graph.facebook.com/&lt;?php echo he($id) ?&gt;/picture?type=square" alt="&lt;?php echo he($name); ?&gt;"&gt;
            &lt;?php echo he($name); ?&gt;
          &lt;/a&gt;
        &lt;/li&gt;
        &lt;?php
        }
          }
        ?&gt;
      &lt;/ul&gt;
    &lt;/div&gt;
  
    &lt;div class="list"&gt;
      &lt;h3&gt;Azaad Friends&lt;/h3&gt;
      &lt;ul class="friends"&gt;
        &lt;?php
          foreach ($app_using_friends as $auf) {
            // Extract the pieces of info we need from the requests above
            $id = idx($auf, 'uid');
            $name = idx($auf, 'name');
        $r_status = idx($auf, 'relationship_status');
        if($r_status == "Single"){
            $aazaads++;
        ?&gt;
        &lt;li&gt;
          &lt;a href="https://www.facebook.com/&lt;?php echo he($id); ?&gt;" target="_top"&gt;
            &lt;img src="https://graph.facebook.com/&lt;?php echo he($id) ?&gt;/picture?type=square" alt="&lt;?php echo he($name); ?&gt;"&gt;
            &lt;?php echo he($name); ?&gt;
          &lt;/a&gt;
        &lt;/li&gt;
        &lt;?php
        }
        $total++;
          }
      $confused = $total - $aazaads - $shaheeds - $in_trap;
        ?&gt;
      &lt;/ul&gt;
    &lt;/div&gt;
    &lt;/section&gt;
  &lt;section id="graphs" class="clearfix"&gt;
  &lt;h1&gt;"Graph"&lt;/h1&gt;
  &lt;img src="http://chart.apis.google.com/chart?cht=p3&amp;chd=t:&lt;?php echo he($shaheeds)?&gt;,&lt;?php echo he($aazaads)?&gt;,&lt;?php echo he($in_trap)?&gt;,&lt;?php echo he($confused)?&gt;&amp;chs=250x100&amp;chl=Shaheed|Aazaad|In Trap|Unknown" /&gt;
  &lt;/section&gt;
  
    &lt;?php
    }
    ?&gt;
  
    &lt;/body&gt;
    &lt;/html&gt;
  </code></pre>