Facebook Invite Friends API
Wall Script
Follow Me:
Wednesday, July 04, 2012

Facebook Invite Friends API

Have you noticed the new button "Bring Your Friends" just take a quick look at the page position top right. Actually this is Facebook invite friends API system. For implementing this you have to create a Facebook application to setup your webpage canvas URL, just few lines of code but before that your web page should be SSL (https) enable.

Facebook Invite Friends API

Download Script     Live Demo

Facebook Invite Friends API

Facebook Application
You have to create a Facebook application at developers.facebook.com click here. Here selected text is Facebook app id.
Facebook Invite Friends API
Facebook supports only https canvas URL, my next post I will explain how to configure SSL.

Code
You have to modify appId value.
<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>


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

Facebook invite friends screen.
Facebook Invite Friends API

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>

The inivite notification appears like this.
Facebook Invite Friends API
Was this article helpful?
Thanks! Your feedback helps us to improve 9lessons.info


152 comments:

  1. sahi hai bheedooo...;)

    ReplyDelete
  2. Thanks for the script. Worked Perfect.

    ReplyDelete
  3. Thanks for this tutorial I was looking for it.

    ReplyDelete
  4. good article can u please post about the multiselector one ..
    using facebook javascript multi friend selector

    ReplyDelete
  5. Thanks...
    Released this script on time as
    I am currently doing a project which requires this script

    ReplyDelete
  6. it was really very helpfull.

    ReplyDelete
  7. I want to facebook connect.. can you guide me how I can get?? and I have question.. SSL must for facebook connect????

    ReplyDelete
  8. Wow this is what i am expecting...now i can drive more traffic from fb...thanks for your post...

    ReplyDelete
  9. good tutorial.

    ReplyDelete
  10. You missed one thing,
    There isn't a "Select All" check-box...

    It would make life easier for a USER if he/she wants to INVITE all their friends...

    Comes in Handy...

    ReplyDelete
  11. Wowww incredible!!! thank for much

    ReplyDelete
  12. Excellent!
    Thanks for share it!

    ReplyDelete
  13. Absolutely Excellent. Thanks for this!

    ReplyDelete
  14. thanks, but how to get the number who accept the invite? and the name list?

    ReplyDelete
  15. thanks its really useful

    ReplyDelete
  16. You are great. Thanks for the article.

    ReplyDelete
  17. Nice tutorial.. How to get the number of persons that the message sent in the return url ?

    ReplyDelete
  18. still a lot is available in facebook sdks

    ReplyDelete
  19. what if I don't want to use javascript side and I prefer to use a server side php script... I mean, from php, launch that dialog request??

    nice article...very helpfull

    ReplyDelete
  20. wow i love that tutorial thanks man

    ReplyDelete
  21. waiting for the ssl configuring

    ReplyDelete
  22. Very important post. Great !!

    ReplyDelete
  23. thnx for info. but what are the disadvantages of using facebook api for inviting friends?

    ReplyDelete
  24. Nice one.
    But i don't think people would accept these requests , where farm ville and other shit ville requests make people irritating.

    ReplyDelete
  25. getting error on API_ID of facebook help me

    ReplyDelete
  26. Hello, well i want to thank you so so much for this code. I actually add it on my website and works so fine. i wait for results and let you know soon. Thanks again!

    ReplyDelete
  27. API Error Code: 191
    API Error Description: The specified URL is not owned by the application
    Error Message: redirect_uri is not owned by the application.

    ReplyDelete
  28. it cannot reditect to any site or any where pls

    ReplyDelete
  29. send invitation to friend then it show in notification and then click on it where to redirect explain this code pls hlp me

    ReplyDelete
  30. Code is very Useful, but can I know the way how to exclude those friends that are already registered on my site

    ReplyDelete
  31. Great website. Lots of helpful information here. I am sending it to some friends and also sharing in delicious. And obviously, thank you in your effort!

    ReplyDelete
  32. Quite helpful blog.
    Those who are facing errors, please make sure that your URL is given properly as App Domains. This will solve errors.

    ReplyDelete
  33. Great post : is this possible to add our fanpage ?

    ReplyDelete
  34. Thanks for your script.very helpfull.

    I had implemented your code,but still mysite is showing inside facebook page.

    how to redirect it?


    Thanks

    ReplyDelete
  35. Please help i got the error
    "An error occurred. Please try later"

    ReplyDelete
  36. Exactly what I am looking for ! Thanks

    ReplyDelete
  37. Very Helpful I like very much

    Thanks

    ReplyDelete
  38. Hi,

    I downloaded source code.I given activated appid,but for me showing following error,
    An error occurred. Please try again later.

    API Error Code: 191
    API Error Description: The specified URL is not owned by the application
    Error Message: redirect_uri is not owned by the application.

    Please help me...
    Thanks,
    Prasad.

    ReplyDelete
  39. Working on localhost, not on a domain, but within my Facebook app settings I've set a different, existing website. I keep getting this error:

    API Error Code: 191
    API Error Description: The specified URL is not owned by the application
    Error Message: redirect_uri is not owned by the application.

    In the firebug console I get this:

    Given URL is not allowed by the Application configuration.: One or more of the given URLs is not allowed by the App's settings. It must match the Website URL or Canvas URL, or the domain must be a subdomain of one of the App's domains.

    Does this mean this will not work on localhost?

    ReplyDelete
  40. thanks for this nice tutorial

    ReplyDelete
  41. Awesome, seamlessly integrated into my site :)
    Thank you Srinivas

    ReplyDelete
  42. Thank you so much for this artcile. It helps me alot

    ReplyDelete
  43. How do you get the blue image to appear over the dialog?

    ReplyDelete
  44. API Error Code: 191
    API Error Description: The specified URL is not owned by the application
    Error Message: redirect_uri is not owned by the application.

    ReplyDelete
  45. Great Tutorial...But it should stay on page after click on submit button or it should display that invitation sent successfully and all, currently inviter window get disappeared when we invite

    ReplyDelete
  46. How do you do it so you dont need a pop up window? Ive noticed sites like quora... when you login, they will show a list of friends to invite right on the page.

    ReplyDelete
  47. Thanks for script...
    I need you help with the Invite Friends API How I can to do to redirect an aplication when a friend accept the application it's lik = http://apps.facebook.com/lae_espana_icte_uq but I want to redirect = fan page application

    ReplyDelete
  48. hi

    that code, work with Page Tab?

    BR

    ReplyDelete
  49. after sending the invitation, the concerned person is not getting any notification on facebook.

    Is there any configuration that needs to be done?

    ReplyDelete
  50. Hi,
    I have fellow this tutorial but none of my selected friends get a notification...
    Does anyone get also this issue ?

    ReplyDelete
  51. good code, very useful... big thanks.

    ReplyDelete
  52. Nice Article. Thanks

    ReplyDelete
  53. nice post.. it hepled me a lot

    ReplyDelete
  54. Hallo 9lessons.greate artikel,ferry nice.

    Can you help me. My qustion is.how to redrirect to another web page after user invite their friends.like a Thanks Page.

    sorry about my english....!.Thnks :)

    ReplyDelete
  55. Hallo 9lessons, actually i am using the same code in grails Application, so fine the pop is coming with my friend list,and when i select one of my friend and click on send button request is send but the notification is not coming in friends wall, i did all configuration very well, so can you just more elaborate how it will work for mine.i am very glade if you give me a response

    ReplyDelete
  56. its very helpfull.. thnx

    ReplyDelete
  57. For those who has not received the notification try to disable sandbox mod for the app. I had the same problem, but after the sandbox mode was disabled the notification appears on friends wall

    ReplyDelete
  58. Facebook is note redirecting to me

    ReplyDelete
  59. Will this trigger a mail to friend's email.

    ReplyDelete
  60. I want to offer scheme as a gift after 100 like as per invited from particular one user reference

    Small base Affiliation System for tracking there inviting user is proceed or not cross 100 like

    Any body have Idea?

    ReplyDelete
  61. When you receive a friend's request, it simply redirects to your website instead of facebook app / canvas page....
    Please specify what trick did you use for that

    ReplyDelete
  62. Very helpful application for me, thank's for sharing

    ReplyDelete
  63. very good tutorial, i enjoy it, bookmarked already !

    ReplyDelete
  64. API Error Code: 191
    API Error Description: The specified URL is not owned by the application
    Error Message: redirect_uri is not owned by the application.


    can u please explain me about this error???

    ReplyDelete
  65. thank you very much ,i tried a lot of way but it works fine thank .

    ReplyDelete
  66. When you receive a friend's request, it simply redirects to your website instead of facebook app / canvas page....
    Please specify what trick did you use for that

    ReplyDelete
  67. hello... Can you say how can I change text 'Preview of request'?

    ReplyDelete
  68. hello everyone i am able to open the request pop up but the invitations are not coming to the accounts

    ReplyDelete
  69. Cannot send notifications to a user who has not installed the app

    ReplyDelete
  70. I am able to send apprequest and these are displaying at apprequest section but there is no notification like in your case.

    ReplyDelete
  71. @Sam have you got how to do what you were asking in above comment.

    ReplyDelete
  72. Using Fb.ui method apprequests for website app is the violation of Facebook policy. It is allowed for games, andriod and IOS app only.
    https://developers.facebook.com/docs/reference/dialogs/requests/

    ReplyDelete
  73. hi. why i do same example but when click notification it not redirect to my homepage

    ReplyDelete
  74. Hi! It seemed to work well until i realized nobody can receive any of those notification? How come? Thanks

    ReplyDelete
  75. very good article, but when u say Code IFrame and say to add these code in iframe, what does it mean? where do i have to put these cose? i need this answer, thank you very much!

    ReplyDelete
  76. i get " Method Not Allowed Error 405 " How can i redirect from canvas to website?

    ReplyDelete
  77. I have received any notification. could you please tell me exact reason behind that?

    ReplyDelete
  78. i have used this code but my friend don't received any notification, what is the problem ? please help me using this

    ReplyDelete
  79. like above users.. my friend does not receive any notification while the demo version works..

    ReplyDelete
  80. I am having the same issue that arouse with "farrukh farid" can you please guide us to solve this out......

    ReplyDelete
  81. very nice.
    Is there any way to get back info of how many or which friends were invited?

    ReplyDelete
  82. Hi i am not using app but using fb sdk for sending request to invite friend but it not shown in notification tab in facebook instead of post is there. so what can i do for notification.

    plz give me reply asap....

    thanks in advance.

    ReplyDelete
  83. Hi!

    I tried to do this procedure, but I not found this option: basic info under the settings option.
    Could you help with more details, please?

    ReplyDelete
  84. Hello

    I have implemented same and its working. Notifications displays on friends page but my problem is when click on notification not redirecting to My URL.

    Please help me on this.

    I have Given Both Canvas URL and everything you have mention but still not redirecting on my URL.

    Thanks in Advance.

    ReplyDelete
  85. when click on notification the requested page not redirected..

    what's the problem behind that?pls help

    ReplyDelete
  86. Please help me.
    Actually when i have send invitation then the receiver not getting any notification.
    What will i do...?

    ReplyDelete
  87. i have created this app and use this same code for my website and it works fine.but the receivers to those who receives notification on thier wall cannot get redirected to my website given as canvas url in app while click on notification.


    what is that problem.any help will be greatly appreciated.

    ReplyDelete
  88. i have send invitation then the receiver not getting any notification.

    ReplyDelete
  89. Hello,
    i have send invitation then the receiver not getting any notification.
    what should i do
    please help

    ReplyDelete
  90. hi notifications not received ,but invite successfull,please help me very urgent

    ReplyDelete
  91. hi notifications not received ,but invite successfull,please help me very urgent

    ReplyDelete
  92. HI
    I am using same code with my api key n all its work but when i send invite to my friends no notification going

    ReplyDelete
  93. Great tutorial, thank you! But like a few others my invites don't reach Facebook. They seem to send but don't. Is there a problem with app approval, or should what you explained just work without any more set up?

    Many Thanks.

    ReplyDelete
  94. Got the invite working but now all i does is invite people to try the app. It didn't do this the first few times, very strange, something in my app set up? Any suggestions welcome, thanks

    ReplyDelete
  95. This works great in woindows but was unable to see the notifications in IOS and android
    Can any one please explain me about this
    thanks in advance

    ReplyDelete
  96. My friend can't get my invitation.

    ReplyDelete
  97. Confirm, it didn't work in fresh api.

    ReplyDelete
  98. Great tutorial...
    i have a question. is there any way to change notification message which is now like 'Sent you request in a (app name)'. i want to add custom message here with a url. is it possible ? if yes then how ? can you please guide ?

    ReplyDelete
  99. those not getting notification simply do
    Go to your app->setting->add platform->App on Facebook. Then fill-up Canvas URL and Secure Canvas URL. And then invite you friends again and enjoy.

    ReplyDelete
  100. I am sending requests, but no notification received at the other end.

    ReplyDelete
  101. For all users facing problem like invitation not received,this script work only if you have created proper "facebook canvas" in facebook app.So if you are using this code to invite to your website,you have to create "facebook canvas" and put https url.Note that in this page(https url) you have to write "javascript url redirection code" which will redirect to your website.

    ReplyDelete
  102. I am getting the error when tried to use the above code
    "Given URL is not allowed by the Application configuration: One or more of the given URLs is not allowed by the App's settings. It must match the Website URL or Canvas URL, or the domain must be a subdomain of one of the App's domains."
    please help me

    ReplyDelete
  103. Hi !
    Is this link goes to your web page or your facebook page ?
    Thanks

    ReplyDelete
  104. Why am i not getting the invite dialog box, if I'm already logged into facebook ?

    It works only if i'm not logged in. anyone else faced this problem ?

    ReplyDelete
  105. I tried this code and it works for me in my older apps. But it is not working on the latest version of app and shows an error like game URL is needed for the app

    ReplyDelete
  106. after disabling sandbox mode i am still not geting notefication

    ReplyDelete
  107. hi... i tried to create fb app and run... im getting "Game Requests are only available to games." error... could u pls let us know how to create app in right way... the screen shots in this tutorial is old way of creating app... could u help us to do it in new way

    ReplyDelete
  108. I have added the "facebook canvas" for app, But no notification in mobile. Please let me know the solutions for this problem.

    Thanks

    ReplyDelete
  109. does this also works with Facebook API 2.5?

    ReplyDelete
  110. My FB app works fine for login, like, share. But still this doesn't work. The fb window appears, you may select your friends and click Done. But the invitations wont go to the friends notifications. Can someone help us?

    ReplyDelete
  111. can we send the custom app request notification to my friends?

    ReplyDelete
  112. can we send the custom notification to my friends

    ReplyDelete
  113. My friends unable to receive notifications.

    ReplyDelete
  114. Invitations wont go to the friends notifications.Please check it..

    ReplyDelete
  115. not work for me, the windown pop up view but only loading

    ReplyDelete
  116. Hey First of all thank you very much for a great tutorial.
    I am using the same code as you mention above, but when i trying to get the friends list it returns me "You app must be game category " like. so Please could you help me out. I don't want to use send-dailog for inviting friends. Is there any other way to render friends for inviting for my website registration.
    Thank you very much.

    ReplyDelete

Make in India