Invite 5 friends to app and more

I am trying to build a new Facebook application that will work only after the user will invite 5 of his friends and more.

So I found the possibility of using general engine inviting friends:

    <title> try </title>
    <div id="fb-root"></div>
    <script src="">
            appId:'****', cookie:true, 
            status:true, xfbml:true 

        function FacebookInviteFriends()
            FB.ui({ method: 'apprequests', 
            message: 'My diaolog...'});
    <a href='#' onclick="FacebookInviteFriends();"> click here</a>

Is there a way to add an option that must enter at least five members, and then transferred to new page? I'm still relatively new to PHP I'd love your help.


If you are after sending a apprequest to selected friends you can keep the selected friends Id in session and read it from your FacebookInviteFriends method.

function FacebookInviteFriends() { FB.ui({ method: 'apprequests', message: 'My diaolog...'}); to: '<ids from session>' }

I think this question is not related to facebook or it's php sdk, but anyway, you can do it in so many ways I think. I do something like that in one app I just released:

1) In the FB.ui method, add the max_recipients option, like this: FB.ui({ method: 'apprequests', message: 'My diaolog...', max_recipients: 1 });

2) Remember that the ui method allows you to attach a callback to it, so you can do something like this: FB.ui({ method: 'apprequests', message: 'My diaolog...', max_recipients: 1 },function(response){ console.log(response) });

In this response variable you have the ID of the user selected.

What I do next is to populate a form using this response. I have a form with hidden fields like this:

<form id="miform">
<input type="hidden" name="friend1" value="" id="f1">
<input type="hidden" name="friend2" value="" id="f2">
<input type="hidden" name="friend3" value="" id="f3">
<input type="hidden" name="friend4" value="" id="f4">
<input type="hidden" name="friend5" value="" id="f5">

With jquery, I populate the hidden inputs (remember, we're still inside the callback function):


3) The last step is the validation, you can do it with javascript or php:

// check if the fields are not empty and submit the form or alert if the fields are empty.

Hope this gives you a more clear view of what you have to do.


Need Your Help

How can I reduce memory in VB.NET Windows application? memory out-of-memory

I am working on VB.NET multiuser application and whenever any of my forms opens up - memory rises, and after some time OutOfMemoryException is thrown.

Showing a popup in Swing indicating progress of program startup

java swing jframe jpanel jdialog

I have a JFrame class where it's constructor will take a little bit of time (in some occasions) to create all the appropriate objects.