title: Problems Implementing Facebook Friends Selector Dialogue Using PHP SDK
body: <p>I am trying to figure out how to properly implement the friends selector dialogue for app requests.</p>
  
  <p>What I am aiming for is, once the user has entered my competition app, if they don't win they can choose to send a request to 5 friends and then they will get another chance to enter.</p>
  
  <p>I have no idea if it's possible to enforce a minimum of 5 friends to be selected but the logic for controlling whether they can enter or not will be controlled by some data stored in the database, i.e once the request is sent, update the db to allow them to re-enter.</p>
  
  <p>I followed the code in this question:</p>
  
  <p><a href="https://stackoverflow.com/questions/8505410/how-to-display-the-friends-selector-dialog-with-php-sdk-for-facebook">How to display the friends selector dialog with PHP sdk for Facebook?</a></p>
  
  <pre><code>// Create our Application instance (replace this with your appId and secret).
  $facebook = new Facebook(array(
      'appId' =&gt; 'XXXXXXXXX',
      'secret' =&gt; 'XXXXXXXXXXXXXXXXXX',
  ));
  
  $user = $facebook-&gt;getUser();
  
  $url = 'https://www.facebook.com/dialog/';
  $url .= 'apprequests?app_id=XXXXXXXXXX&amp;redirect_uri=http://www.domain.com/';
  $url .= '&amp;message=Share%20with%205%20friends%20for%20another%20chance%20to%20win!&amp;display=popup';
  ?&gt;
  &lt;a href="&lt;?php echo $url; ?&gt;"&gt;Recommend friends for another chance to win!&lt;/a&gt;
  
  &lt;?php
  
  echo $_GET['request_ids'];
  
  if (isset($_GET['request_ids'])) {
      for ($i=0; $i&lt;count(request_ids); $i++){
          $link = ($link + "&amp;to=" + $request_ids[$i]);
      }
      echo "&lt;script language=javascript&gt;parent.location=''&lt;/script&gt;";
  }
  </code></pre>
  
  <p>The problems I am having are that when I click the link, the facebook logo then appears with 'go to facebook.com' underneath. When I click this, the dialogue opens in a full page.</p>
  
  <p>If I click cancel, it takes me to my domain but can it not redirect to the tab?</p>
  
  <p>Likewise, if I complete the app request dialogue I am redirected to my homepage when I would rather be re-directed to the tab.</p>
  
  <p>Having a hard time getting my head around this so help would be greatly appreciated.</p>
  
  <p>To summarise, I would like to have the dialogue open in a popup, rather than the facebook logo suddenly appearing and then the dialogue opening in the page.</p>
  
  <p>Then, if the user clicks 'cancel' for the dialogue to simply close and if the request is completed, for the dialogue to close again, leaving the tab instead of the dialogue being a full page and redirecting to my domain.</p>
  
  <p>Thanks.</p>