Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6955339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:43:25+00:00 2026-05-27T14:43:25+00:00

I am trying to figure out how to properly implement the friends selector dialogue

  • 0

I am trying to figure out how to properly implement the friends selector dialogue for app requests.

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.

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.

I followed the code in this question:

How to display the friends selector dialog with PHP sdk for Facebook?

// Create our Application instance (replace this with your appId and secret).
$facebook = new Facebook(array(
    'appId' => 'XXXXXXXXX',
    'secret' => 'XXXXXXXXXXXXXXXXXX',
));

$user = $facebook->getUser();

$url = 'https://www.facebook.com/dialog/';
$url .= 'apprequests?app_id=XXXXXXXXXX&redirect_uri=http://www.domain.com/';
$url .= '&message=Share%20with%205%20friends%20for%20another%20chance%20to%20win!&display=popup';
?>
<a href="<?php echo $url; ?>">Recommend friends for another chance to win!</a>

<?php

echo $_GET['request_ids'];

if (isset($_GET['request_ids'])) {
    for ($i=0; $i<count(request_ids); $i++){
        $link = ($link + "&to=" + $request_ids[$i]);
    }
    echo "<script language=javascript>parent.location=''</script>";
}

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.

If I click cancel, it takes me to my domain but can it not redirect to the tab?

Likewise, if I complete the app request dialogue I am redirected to my homepage when I would rather be re-directed to the tab.

Having a hard time getting my head around this so help would be greatly appreciated.

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.

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.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T14:43:26+00:00Added an answer on May 27, 2026 at 2:43 pm

    Using the Facebook JS-SDK would provide the best experience you are asking for. If that’s an option (can’t think why it won’t be), then you should use the Requests Dialog:

    <html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:fb="https://www.facebook.com/2008/fbml">
      <head>
        <title>Request Tester C</title>
      </head>
    
      <body>
        <div id="fb-root"></div>
        <script src="http://connect.facebook.net/en_US/all.js"></script>
        <p>
          <input type="button"
            onclick="sendRequestToRecipients(); return false;"
            value="Send Request to Users Directly"
          />
          <input type="text" value="User ID" name="user_ids" />
          </p>
        <p>
        <input type="button"
          onclick="sendRequestViaMultiFriendSelector(); return false;"
          value="Send Request to Many Users with MFS"
        />
        </p>
    
        <script>
          FB.init({
            appId  : 'YOUR_APP_ID',
            status : true,
            cookie : true,
            oauth: true
          });
    
          function sendRequestToRecipients() {
            var user_ids = document.getElementsByName("user_ids")[0].value;
            FB.ui({method: 'apprequests',
              message: 'My Great Request',
              to: user_ids, 
            }, requestCallback);
          }
    
          function sendRequestViaMultiFriendSelector() {
            FB.ui({method: 'apprequests',
              message: 'My Great Request'
            }, requestCallback);
          }
    
          function requestCallback(response) {
            // Handle callback here
          }
        </script>
      </body>
    </html>
    

    How to handle the requests sent is also described in the documentation and also in my tutorial; below is an example of handling the callback with the new requests format (I’m using jQuery):

    function sendRequest() {
        FB.ui({
            method: 'apprequests',
            message: 'I want to give you this flower!',
            title: 'Give a flower to some of your friends',
            data: '{"item_id":1254,"item_type":"plant"}'
        },
        function (response) {
            if (response.request && response.to) {
                var request_ids = [];
                for(i=0; i<response.to.length; i++) {
                    var temp = response.request + '_' + response.to[i];
                    request_ids.push(temp);
                }
                var requests = request_ids.join(',');
                $.post('handle_requests.php',{uid: <?php echo $user; ?>, request_ids: requests},function(resp) {
                    // callback after storing the requests
                });
            } else {
                alert('canceled');
            }
        });
        return false;
    }
    

    UPDATE: As for the “minimum” # of friends requirement. The JS-SDK dialog has a max_recipients property but no minimum, so you need to have your own friend selector then set the to property to those friends’ ids.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to figure out how to properly serialize my XmlDocument and send it
Trying to figure out how I can do this properly. The print_r looks like
Trying to figure out how to identify unique users properly with cookies and perhaps
Trying to figure out why my silverlight app suddenly just displays nothing (right click
I have been trying to figure out how to implement a simple xml rpc
I'm trying to figure out how to properly store foreign keys when the key
I'm trying to figure out where to properly set tableView.rowHeight. Currently I have it
I'm trying to figure out how to structure data properly in PHP in order
I've run into a problem trying to implement a Menu and can't figure out
I'm trying to figure out how to properly use the OpenSSL.Session API in a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.