Facebook Custom Login Button has the same purpose as Facebook Login Button, but while Facebook Login Button has predefined appearance which is rendered on Facebook server, Custom Login Button can be defined by user. It has 4 different types: button, link, image, and auto open on page load. It is possible to set style with CSS.

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.


Login Button Images

Following image represents 4 types of Custom Login Buttons: link, button, button with defined CSS style, and image.

facebook login button


PHP Example

The example shows a code for creating 4 Facebook Custom Login Buttons from the picture above. The example shows the code for the whole page, but important content is highlighted. Required includes and initialization for any page is highlighted with brown color. Working with Facebook Login Button PHP class is highlighted with blue color.

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">
    <head>
       <title>Facebook Login Button PHP example</title>
    </head>
    <body>
        <?php
            require_once 'facebook.php';
            require_once 'faceconn/faceconn.php';
            UseGraphAPI();
        ?>
               
        <form id="form1" >
            <?php
                $login = new CustomLoginButton();
                $login->SetCommandText("Connect with Facebook");
                $login->Render();

                $login->SetCommandType("link");
                $login->Render();

                $login->SetCssClass("blue command_button");
                $login->Render();

                $login->SetImage("images/fblogin.png");
                $login->Render();
            ?>
        </form>
    </body>
</html>



Facebook Custom Login Button 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 Custom Login Button Demo page.


Configuration

Configuration of the Facebook Login Button PHP class is done through calls of the setter methods, which in turn set the private properties. For Facebook Login Button 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 login button php
Method Name
Type
Description
facebook extended permissions php
SetCommandType
String
Function sets the type of command control. Allowed values are 'link', 'button', 'image', and 'auto'. Default value is 'button'.
facebook extended permissions php
SetCommandText
String
Function sets the title of login button/link. Default value is 'Login'.
facebook login button php
SetImage
String
Function sets image of login button. Image type is set automatically.
facebook login button php
SetOnLoginSubmitForm
String
Function sets the form ID to be submitted after the user is logged in.
facebook login button php
SetOnLoginJavaScript
String
Function sets the JavaScript code to be executed after the user is logged in.
facebook login button php
SetPermissions
String
Function sets required permissions (in comma separated list form).