Sourav
Sourav

Reputation: 17530

Invite friends to an application - Facebook

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>

Upvotes: 3

Views: 14425

Answers (5)

جعفر علي
جعفر علي

Reputation: 1

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; ?>',
    });
}

Upvotes: -1

pal4life
pal4life

Reputation: 3378

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>

Upvotes: 1

Sourav
Sourav

Reputation: 17530

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; ?>',
           });
}

Upvotes: 1

bkaid
bkaid

Reputation: 52063

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.

Upvotes: 3

Craig White
Craig White

Reputation: 13992

Have you tried checking the pages source/html? Maybe there are some errors reporting. You can also in PHP call error_reporting(E_ALL); which will enable all errors to be printed instead of being hidden.

Also, perhaps you could check your browsers JavaScript logs for errors.

In Internet Explorer 9 press F12

In Firefox download firebug.

In Chrome press CTRL + SHIFT + J

Upvotes: 0

Related Questions