Facebook Invite Friends class is used to send the invite requests to the user's friends, to use Facebook application or Facebook Connect website. There are two types of the invite control: a classic one and condensed one. This tutorial contains description of both controls, one after another.

Note: This feature is deprecated by Facebook. Please use Facebook Request Dialog instead.
These classes are members of Facebook Connect PHP Toolkit. To see all classes from the toolkit, please look at the Facebook Connect Graph API classes.


Facebook Invite Friends Classic

Invite Friends Classic Image

This image shows classic Facebook Invite control with default settings. Pictures of friends and last names are hidden, because of privacy protection. The picture shows the Invite control after the send button is pressed. Preview of invite request is shown too.

facebook invite friends



PHP Example

The example shows the configuration of default Facebook Invite Friends control, with only mandatory parameters being set. Action URL, Accept URL and application name are taken from AppConfig.php class, as default settings. The example shows the code of whole page, but important content is highlighted: required includes and initialization for any page with brown color, and working with Facebook Invite Friends PHP class with blue color.

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">
    <head>
       <title>Facebook Invite Friends PHP Example</title>
    </head>
    <body>
        <?php
            require_once 'facebook.php';
            require_once 'faceconn/faceconn.php';
            UseGraphAPI();
            
            $invite1 = new InviteFriends();
            $invite1->SetMainTitle("Main title");
            $invite1->SetContent("This is Facebook invite friends content.");                        
            $invite1->Render();
        ?>    
    </body>
</html>



Facebook Invite Friends PHP class has a demo page inside Demo Website where it can be seen how it works. The most important fact is that the Demo website is contained in package with Facebook Connect PHP Toolkit which is very useful resource of code examples for each control from the toolkit. Look at the Facebook Invite Friends Demo page.


Configuration

Configuration of the Facebook Invite Friends PHP class is done through calls of the setter methods, which in turn set the private properties. There are couple of mandatory properties and couple of optional ones which are set by default. After the configuration is set, all you have to do is to call Render() method, and the control will display on page.


Setting mandatory properties

facebook invite friends php
Method Name
Type
Description
facebook invite friends php
SetContent
String
Function sets the description which should be displayed on the invite request.
facebook invite friends php
SetMainTitle
String
Function sets the title of message inside the invite control.



Setting optional properties

facebook invite friends php
Method Name
Type
Description
facebook invite friends php
SetActionUrl
String
Function sets the URL where application should be redirected, after an invitation is sent. Default is application Canvas URL taken from AppConfig class
facebook invite friends php
SetAcceptUrl
String
Function sets the URL where user will be redirected after the invite request is accepted. If it's not set, ActionUrl is used.
facebook invite friends php
SetAppName
String
Function sets the name of application. Default is name taken from AppConfig class.
facebook invite friends php
SetConfirmButtonText
String
Function sets the text of the confirm button. Default value is 'Accept'
facebook invite friends php
SetShowBorder
Bool
Call this function with the parameter set to true to display the border. Default value is true. If it's not set, ActionUrl is used.
facebook invite friends php
SetEmailInvite
Bool
Call this function with the parameter set to true to show the email invite section.
facebook invite friends php
SetRowsCount
Int
Function sets the number of rows. Allowed values are from 3 to 10. Default value is 5.
facebook invite friends php
SetColumsCount
Int
Function sets the number of columns. Allowed values are from 2, 3 and 15. Default value is 5.
facebook invite friends php
SetWidth
Int
Function sets the width of rows. Default value is 760.
facebook invite friends php
SetExcludeFriends
String
Function sets the comma separated list of friends which should not be displayed in the invite control.
facebook invite friends php
SetCssStyle
String
Function sets the CSS style.
facebook invite friends php
SetCssClass
String
Function sets the CSS class.




Facebook Invite Friends Condensed

Invite Friends Condensed Image

This image shows condensed Facebook Invite PHP class with default settings. Friends' last names are hidden because of privacy protection. The picture shows the Invite control before the send button is pressed. After it is pressed, the same invite friends request is shown, like for Facebook Invite Friends classic control.

facebook invite friends condensed



PHP Example

The example shows the configuration of default Facebook Invite Friends control, with only mandatory parameters being set Action URL, Accept URL and application name are taken from AppConfig.php class, as default settings. The example shows the code of whole page, but important content is highlighted: required includes and initialization for any page with brown color, and working with Facebook Invite Friends PHP class with blue color.

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">
    <head>
       <title>Facebook Invite Friends PHP example</title>
    </head>
    <body>
        <?php
            require_once 'facebook.php';
            require_once 'faceconn/faceconn.php';
            UseGraphAPI();
            
            $invite2 = new InviteFriendsCondensed();
            $invite2->SetContent("Content");
            $invite2->Render();
        ?>    
    </body>
</html>




Facebook Invite Friends PHP class has a demo page inside Demo Website where it can be seen how it works. The most important fact is that the Demo website is contained in package with Facebook Connect PHP Toolkit which is very useful resource of code examples for each control from the toolkit. Look at the Facebook Invite Friends Demo page.


Configuration

Configuration of the Facebook Invite Friends Condensed PHP class is done through calls of the setter methods, which in turn set the private properties. There are couple of mandatory properties and couple of optional ones which are set by default. After the configuration is set, all you have to do is to call Render() method, and the control will display on page.


Setting mandatory properties

facebook invite friends php
Method Name
Type
Description
facebook invite friends php
SetContent
String
Function sets the description which should be displayed on the invite request.



Setting optional properties

facebook invite friends php
Method Name
Type
Description
facebook invite friends php
SetActionUrl
String
Function sets the URL where application should be redirected, after an invitation is sent. Default is application Canvas URL taken from AppConfig class
facebook invite friends php
SetAcceptUrl
String
Function sets the URL where user will be redirected after the invite request is accepted. If it's not set, ActionUrl is used.
facebook invite friends php
SetAppName
String
Function sets the name of application. Default is name taken from AppConfig class.
facebook invite friends php
SetConfirmButtonText
String
Function sets the text of the confirm button. Default values is 'Accept'
facebook invite friends php
SetSelectorWidth
Int
Function sets the width of the control selector in pixels.
facebook invite friends php
SetUnselectedRowsCount
Int
Function sets the number of unselected rows to be displayed. Allowed values are from 4 to 15. Default value is 6.
facebook invite friends php
SetSelectedRowsCount
Int
Function sets the number of selected rows to be displayed. Allowed values are from 5 to 15. Default value is 5.
facebook invite friends php
SetWidth
Int
Function sets the width of rows. Default value is 760.
facebook invite friends php
SetExcludeFriends
String
Function sets the comma separated list of friends which should not be displayed in the invite control.
facebook invite friends php
SetCssStyle
String
Function sets the CSS style.
facebook invite friends php
SetCssClass
String
Function sets the CSS class.