Search code examples
facebookxfbml

Facebook Requests doesn't work


I'm trying to gets new user whit Facebook Requests. Unfortunally when an user accept the invite from facebook he is redirected to https://www.facebook.com/?request_ids=xxxxxxxxxxx and not to my website. i tryed to pass the userid to facebook but i don't receive any "postback". what it's wrong whit my app? i need to change app settings or is my code wrong?

     <div id="fb-root"></div>
     <script src="http://connect.facebook.net/en_US/all.js"></script>
     <script>
    function invitefacebook(){
       FB.init({appId: 'xxxxxxxxxxxx', xfbml: true, cookie: true});
    FB.ui({
    method: 'apprequests',
    message: 'I invite you in this awesome website!',
    data: '<?php echo $id; ?>'});

    }
    </script>
<a onclick="invitefacebook();">Invite Friends</a>

Thanks in advance :D


Solution

  • Even though it redirects to the facebook.com you can see your application either as an iframe or as a tab inside that url itself.

    so you should code your app such that you do something when you get the request_ids in the url..

    So do something like this

    if(isset($_REQUEST['request_ids'])){
     //here you can get the current logged in FBuser using you SDK 
     //and then just write some code, where you can either store them as 
     //accepted invitation in db or anything as you wish.
    }
    

    The above code should present in the page which will be displayed as an iframe when the user is redirected to the app.