Facebook invite friends api using javascript

Today i am  using facebook invite friend api in my project .Before using of below code you have to create a Facebook application at developers.facebook.com click here  like below preview. 


Code : You have to modify appId value with your APP_ID :

<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
FB.init({
appId:'APP_ID',cookie:true,
status:true,
xfbml:true
});

function FacebookInviteFriends()
{

FB.ui({
method: 'apprequests',
message: 'Your Message diaolog'
});

}
</script>

BELOW IS THE HTML CODE :

<div id="fb-root"></div>
<a href='#' onclick="FacebookInviteFriends();">
Facebook Invite Friends Link
</a>

Code IFrame : The following code is for breaking Iframe, include this code into your webpage.


<script type='text/javascript'>
if (top.location!= self.location){
top.location = self.location
}
</script>


Below is the sample window of Facebook Invite friends :





If you like this post please don't forgot to notify me to post a comment .

Happy Coding Guys :)

14 Comments

  1. And where is PHP code...?

    ReplyDelete
  2. Hello @RR-team,

    No need of php. Here you need simple javascript that i am using.

    Thanks..

    ReplyDelete
  3. no one can receive the invitation what should i do

    ReplyDelete
  4. SEND INVITATION SUCCESS BUT NOT RECEIVE ANY NOTIFICATION OF MY FRIEND,
    PLEASE SUGGEST ME.

    ReplyDelete
  5. Hi @chetan..

    I thing this is the problem in your facebook app configuration. Please try to follow the below configuration.

    You just need to go in to the Facebook developer and select your app and goes in to the setting of your app and click "Add Platform" and select "App On Facebook" and than add canvas url in it. Now try to send invitation and it will show the notification.

    ReplyDelete
  6. Inwizards is a Website and mobile app design and developement Comapny. We create website in many plateform like : HTML, PHP, Nodejs, asp.net, Angularjs.
    Hire Angularjs Developer
    Hire Nodejs Developers
    hire asp.net developer

    ReplyDelete
  7. hlo,
    friends show smoothly but notification not send to friend. please suggest..

    ReplyDelete
  8. Hi @Amit..

    Thanks for your comment. I thing this is the problem in your facebook app configuration. Please try to follow the below configuration.

    You just need to go in to the Facebook developer and select your app and goes in to the setting of your app and click "Add Platform" and select "App On Facebook" and than add canvas url in it. Now try to send invitation and it will show the notification.

    Please let me know if you still have any issue.

    ReplyDelete
  9. Hi Fuse Angular,
    This code is work with javascript. There is not need of PHP.

    ReplyDelete
  10. I'm getting this error :-
    Game Requests are only available to games.

    ReplyDelete
  11. Hi Quicky,
    Did you add the APP_ID at this line "appId:'APP_ID'" ?

    Show me your code that you are using.

    ReplyDelete
  12. Not work for me,showing error as below,
    Uncaught ReferenceError: FB is not defined

    ReplyDelete
Previous Post Next Post