Invite friends to an application - Facebook

14,384

Solution 1

Now to invite friends the only way is to use FB JS the code

function showInvite()
{
<?php
if (strlen($fbconfig['appname' ])>50)
{
 $title = substr($fbconfig['appname' ],0,45);
 $title = $title . ' ...';
}
else
 $title = $fbconfig['appname' ];

if (strlen($fbconfig['appBaseUrl'])>200)
{
 $message = substr($fbconfig['appBaseUrl'],0,200);
 $message = 'I just love this App, now it\'s your turn to try it @ '.$message;
}
else
 $message ='I just love this App, now it"s your turn to try it @ '.$fbconfig['appBaseUrl'];
?>
 var r = FB.ui({ 
            method : 'apprequests',
            message: '<?php echo $message; ?>',
            title: '<?php echo $title; ?>',
           });
}

Solution 2

Facebook has deprecated this legacy FBML plugin. While it may still work for a while, you will want to upgrade to their new Requests Dialog, which will be easier to get support for. Also, I've noticed some other deprecated features stop working lately (yet they haven't officially been killed), so this may be the case. But check the javascript console for any errors and post them.

Solution 3

Try out code on this page, it would certainly help https://developers.facebook.com/docs/reference/dialogs/requests/

Seems like this is what you are looking for

<script>
   FB.init({
    appId  : 'APPID',
    });

   FB.ui({method: 'apprequests', message: 'My Great Request'});                       
</script>
Share:
14,384
Sourav
Author by

Sourav

Hi, I am Sourav Ghosh :) You can find my projects * AJAX Micro Mini Lib [JS] * Autorun Cleaner [VB.NET] * C Code Completer [VB.NET] * DockBar Develop [VB.NET] * ShoutOut-Twitter [ASP.NET + C#] * Ultra Light CAPTCHA [PHP] * Ultra Light Forum [PHP] * Wallpaper Changer [VB.NET]** @ http://sourceforge.net/users/sourav1989 I'll be really happy if you find them useful :) Thanks :)

Updated on June 04, 2022

Comments

  • Sourav
    Sourav almost 2 years

    Previously my this code worked well but now it do nothing
    I want to show an dialog then the user will be able to select some friends and invite them to use this application.
    Now this code shows blank page.

    <?php
    include_once "fbmain.php";
    if (isset($_REQUEST['ids'])){
    echo "Invitation Sent";
        $string = "<script type='text/javascript'>top.location.href='{$fbconfig['appBaseUrl']}';</script>";
        echo $string;
    }
    else {
    ?>
     <fb:serverFbml style="width: 500px;">
     <script type="text/fbml">
      <fb:fbml>
          <fb:request-form
                    action="<?=$fbconfig['baseUrl']?>/invite.php"
                    target="_top"
                    method="POST"
                    invite="true"
                    type= <?php echo $fbconfig['appname']; ?>
                    content="I tried this and love this, what about you ? <fb:req-choice url='<?php echo $fbconfig['appBaseUrl']; ?>' label='Accept' />"
                    >
    
                    <fb:multi-friend-selector
                    showborder="false"
                    actiontext=<?php echo $fbconfig['appname' ]; ?>>
        </fb:request-form>
      </fb:fbml>
    </script>