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.