Facebook Recommendations PHP class is used to show a list of interesting content for particular domain. The list is created depending on user's personal preferences and shared content by other people.

This class is a member of Facebook Connect PHP Toolkit. To see all classes from the toolkit, please look at the Facebook Connect Graph API classes.


Facebook Recommendations Image

Following image shows the default Facebook Recommendations look, which is used the most often on web sites.

facebook recommendations


PHP example

The example shows default Facebook Recommendations control for domain 'developers.facebook.com', which is shown on picture above. 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 Recommendations PHP class with blue color.

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">
    <head>
       <title>Facebook Recommendations PHP example</title>
    </head>
    <body>
        <?php
            require_once 'facebook.php';
            require_once 'faceconn/faceconn.php';
            UseGraphAPI();

            $recomendations = new Recommendations();
            $recomendations->SetDomain("developers.facebook.com");
            $recomendations->Render();
        ?>
        </body>
</html>



Facebook Recommendations 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 Recommendations Demo page.


Configuration

Configuration for Facebook Recommendations PHP class is done through calls of the setter methods, which in turn set the private properties. For Facebook Recommendations PHP class, there are no required properties to set. All you have to do is to create new instance of the class and call Render() method. All properties from the list below are optional.

facebook recommendations php
Method Name
Type
Description
facebook recommendations php
SetDomain
String
Function sets the domain for which to show recommendations. Default domain is web site on which the page with control is located.
facebook recommendations php
SetWidth
Int
Function sets the width of the control in pixels. Default value is 300.
facebook recommendations php
SetHeight
Int
Function sets the height of the control in pixels. Default value is 300.
facebook recommendations php
SetShowHeader
Bool
Call this function with the parameter set to true to show the header.
facebook recommendations php
SetColorScheme
String
Function sets the color scheme. Available values are 'light' and 'dark'. Default value is 'light'.
facebook recommendations php
SetFont
String
Function sets the font inside the control. Available values are 'arial', 'lucida grande', 'segoe ui', 'tahoma', 'trebuchet ms' and 'verdana'.