One thing I noticed a lot of people ask for on Facebook applications is a way to have users invite friends. I will post the code below I use on my applications to let users invite friends. Below is an image showing you what it looks like in the application. Where the question marks are is where the friend’s face would be and then the friend’s name would be in place of where it says friend’s name.

Here is the code used to produce this with PHP. [ Download Here ]
You will need to look the code over and put your correct web addresses in for your application. I also named this page invite.php on my server. If you have any questions or suggestions just let me know. I am sure I will be tweaking this code from here on out.
on Jul 17th, 2007 at 1:45 pm
Hi Dustin,
thanks for posting this code, I’m trying to implement it on my own app. How do I do this - I’ve built a fbook app but am using java so am unfamiliar with PHP library. At the top of your code is require_once ‘./appinclude.php’;
what is in appinclude.php??
Also does my user need to be logged in to call this page.
Thanks again for publishing code and sorry if this is a bit of a newbie question
John
on Jul 17th, 2007 at 3:02 pm
Sorry about that. The appinclude.php file is the file that sets up the facebook connection. I have now added this file to the download. If you have any more questions just let me know.
on Jul 22nd, 2007 at 9:50 am
Great code! I got it working on my site, but none of the friends pictures are turning up, just a broken image link icon. Whats the trick? Thanks
ret
on Jul 22nd, 2007 at 11:18 am
Roger the images are not loading for anyone right now. Facebook said there is a bug on this and they are currently working to fix it. Your code will display the pictures once they get it worked out.
If you have any more questions or problems just let me know.
on Aug 7th, 2007 at 1:33 pm
Thanks man, a great script!
on Aug 14th, 2007 at 9:48 am
Fantastic code!
Just what I was looking for =)
on Aug 21st, 2007 at 7:19 am
Really helpful
on Aug 27th, 2007 at 4:52 pm
Why is it that every invite script always takes me to a page that says “You’ve already added [[app name]] to your Facebook applications.”??
on Sep 21st, 2007 at 8:41 am
Cheers for the code unfortunately I can seem to view the profile pictures any reason why this would be?
on Sep 23rd, 2007 at 3:05 pm
Thanks a lot! Is the only code I know it really works.
on Oct 3rd, 2007 at 11:02 pm
Great script man, thank you very much
on Oct 18th, 2007 at 1:02 pm
You are a legend! nice skills dude ..
on Oct 25th, 2007 at 1:21 am
Thanks for the great script
on Oct 25th, 2007 at 1:21 am
Great Script, Thanks for the Help.
on Nov 21st, 2007 at 12:38 pm
Hi, i am trying to invite a friend but it appears as ‘ you cannot invite this person’. How to overcome this problem?
on Nov 26th, 2007 at 4:09 pm
[...] have a look for yourself at the Facebook Invite Code or simply download the Facebook Invite Code. Filed under: Facebook [...]
on Nov 27th, 2007 at 10:53 pm
invite you
on Dec 2nd, 2007 at 5:06 am
I got this error when running your code, any idea why?
Fatal error: Uncaught exception ‘FacebookRestClientException’ with message ‘Unknown method’ in /home/a5615504/public_html/client/facebookapi_php5_restlib.php:1316 Stack trace: #0 /home/a5615504/public_html/client/facebookapi_php5_restlib.php(295): FacebookRestClient->call_method(’facebook.notifi…’, Array) #1 /home/a5615504/public_html/invite.php(25): FacebookRestClient->notifications_sendRequest(’539370590′, ‘invitation’, ‘Sela Yair would…’, ‘http://[image p…’, 1) #2 {main} thrown in /home/a5615504/public_html/client/facebookapi_php5_restlib.php on line 1316
on Dec 5th, 2007 at 2:09 am
anyone made this work?
the friends dont display, maybe there is something in the code
on Dec 14th, 2007 at 5:44 am
Thank you so much its very helpful…
on Dec 21st, 2007 at 11:24 am
when a friend accepts the invitation, will the who dey application be notified? for example, i want to track who accepts which invitation.
on Dec 21st, 2007 at 5:13 pm
is there a way to receive notifications when a friend accepts an invitation?
on Dec 21st, 2007 at 5:14 pm
sorry for the double comment. i thought the first one didn’t show up.
i am also wondering if there is a way to send notifications or messages to friends (who have also installed the application).
thanks.!
on Dec 22nd, 2007 at 10:57 pm
Thanks a lot for this
on Dec 27th, 2007 at 2:48 pm
There is a line in appinclude.php:
require_once ‘facebook.php’;
from whr can i download this file??
is this the one which is included in facebook-platform.tar???
i uploaded this file but it showz error!!……
plz help
i want to add invite page to http://apps.facebook.com/lovepoem/
need help
plz mail me!!
thanx
on Dec 29th, 2007 at 9:05 am
thanks
on Jan 4th, 2008 at 5:38 pm
Hi, my app is currently java script in a htm doc… can you tell how a associate you php code to my application.
thanks
simon
on Aug 13th, 2008 at 5:06 am
when i run or use invite.php. i got this error
Fatal error: Call to undefined method FacebookRestClient::notifications_sendRequest() in /home/content/p/u/r/purabdk
/html/googlewala/fb8/invite.php on line 19
line 19 is on invite.php
$send_email_url = $facebook->api_client->notifications_sendRequest($friends_list, ‘invitation’, $fbml_content,’http://googlewala.com/images/one.jpg’, 1);
what is wrong with my code please tell me..
on Aug 26th, 2008 at 4:23 am
Hi,
This is an great example for invite friends on facebook.
But this is not up to date.
In example code you have used some functions which are no longer available.
For example- notifications_sendRequest().
An latest and effected example can be found at-
http://wiki.developers.facebook.com/index.php/Fb:request-form
Thank you.
Regards,
Md. Maksudul Islam
on Aug 31st, 2008 at 3:47 pm
Hello, some of the fb functions used in this script have be depreciated since October of 07. I haven’t been able to figure out how to update this script. Has anyone else?
on Sep 11th, 2008 at 7:56 am
Hi, it works gr8 man thanks
on Nov 10th, 2008 at 9:26 pm
hey how can i make this work? what’s the steps of doing it?