9lessons programming blog
Loading Search
9lessons Bring Friends
Wall Script
Follow Me:
Wednesday, July 4, 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
Comments
{ 121 comments }
Muhammad Duha said...

Good article

Muhammad Duha said...

Good article.

talhachamp said...

ya very usefulll thanks

Amit Karsale said...

sahi hai bheedooo...;)

khaled said...

thank u

Jagan Krishnaraj said...

Thanks for the script. Worked Perfect.

Chiranjeev said...

Thanks for this tutorial I was looking for it.

Alex Whinfield said...

Fantastic post. Thanks :)

V.Vamshi Krishna Reddy said...

Is there a select all button?

V.Vamshi Krishna Reddy said...

how to select all?

தினேஷ் குமார் said...

Thanks,Very useful post

Siddeshwar Vanga said...

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

piyush aggarwal said...

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

Anonymous said...

it was really very helpfull.

Arslan Qamar said...

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

phphunger said...

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

Pratap said...

Nice Post

Willian Levinski Keller said...

Hey man, this is very cool

rony said...

Bookmarked !! nice Job !

Anonymous said...

good tutorial.

Linesh Jose said...

This is very useful :)

vizem said...

thank you Srinivas.

Anonymous said...

This is good

Kunal Varma said...

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...

§ M ® said...

Wowww incredible!!! thank for much

Pierre said...

Great tutorial!
Thanks

Leo said...

nice a millions thanks

manvendra singh said...

Keep it Brother

Ewere Diagboya said...

YOU ARE A GENIUS. I LOVE YOU

Rafael said...

Excellent!
Thanks for share it!

Anonymous said...

Absolutely Excellent. Thanks for this!

All About Us said...

Thank... and goooooo

YouYi1314 said...

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

Anonymous said...

thanks its really useful

dileep kumar said...

You are great. Thanks for the article.

siagung said...

thanks

Anonymous said...

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

Anonymous said...

still a lot is available in facebook sdks

hector said...

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

Tullio said...

Very nice

adworks.pk said...

wow i love that tutorial thanks man

Anonymous said...

waiting for the ssl configuring

Amit Dubey said...

great

Shyamal said...

Very important post. Great !!

Ashish said...

gr8 info. I love this...

Anonymous said...

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

Ahman Adam said...

Thanks for share this.

Hasi Haseeb said...

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

siddhu vydyabhushana said...

getting error on API_ID of facebook help me

WanaFans Exchanger said...

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!

Jerry Almeida said...

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.

Nilesh Rabadiya said...

it cannot reditect to any site or any where pls

Nilesh Rabadiya said...

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

Thelogi90an said...

wow

Ashish Chopra said...

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

Tibi said...

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!

Mittal Patel said...

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

Chandimabe said...

Great post : is this possible to add our fanpage ?

Saravanan said...

Thanks for your script.very helpfull.

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

how to redirect it?


Thanks

jwalant bhandari said...

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

shamsheer said...

Great job.

Meena said...

Exactly what I am looking for ! Thanks

Sonu Sindhu said...

Very Helpful I like very much

Thanks

gudluri siva said...

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.

Aleksander said...

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?

Besin said...

good one thank you....

Nitin said...

nice code thanks for sharing

Akash said...

thanks for this nice tutorial

envira said...

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

Anonymous said...

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

Worldvu.tv said...

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

Anonymous said...

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.

Anonymous said...

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

Anonymous said...

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.

Daniel said...

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

Ankit Pokhrel said...

Nice Article...Thanks!

Julio said...

hi

that code, work with Page Tab?

BR

dev said...

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

Is there any configuration that needs to be done?

Anonymous said...

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

Anonymous said...

good code, very useful... big thanks.

Anonymous said...

NICE POST

Anonymous said...

Nice Article. Thanks

Saul Yasar cemal said...

Thank you so much :)

anji.electron said...

how to select all friends?

abs said...

nice post.. it hepled me a lot

Anonymous said...

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 :)

Brijesh Singh said...

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

Anonymous said...

Great!
Thanks!

Anonymous said...

its very helpfull.. thnx

Ricette said...

nice post. Thanks
Adam

Anonymous said...

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

srihari goud said...

Facebook is note redirecting to me

Karthic said...

Will this trigger a mail to friend's email.

Jatin Gupta said...

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?

Vineet Arora said...

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

Vijendra said...

Very helpful application for me, thank's for sharing

kevin said...

very good tutorial, i enjoy it, bookmarked already !

Anonymous said...

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???

Eldho said...

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

Sam said...

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

digma chauhan said...

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

Teasim said...

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

Anonymous said...

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

Anonymous said...

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

Teasim said...

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

Hemendra Chaudhary said...

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/

tran nguyen said...

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

Anonymous said...

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

Anonymous said...

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!

Trefu Ionescu said...

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

Anonymous said...

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

farrukh farid said...

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

Anonymous said...

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

Anonymous said...

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

keinblog said...

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

Anonymous said...

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.

bhava ni said...

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?

Anonymous said...

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.

bhava ni said...

when click on notification the requested page not redirected..

what's the problem behind that?pls help

Michael Caleb said...

Nice Article. Thanks .essay writers

Anonymous said...

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

Post a Comment