Facebook Logout Button is used to break connection between application and Facebook. It is implemented to supports 4 types of command: button, link, image, and auto open on page load. After log out is executed, it is possible to call JavaScript code to execute some action, or define a form on the page to submit.

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 Logout Button Images

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

facebook logoutbutton


PHP Example

The example shows a code for creating 4 Facebook Logout 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, and 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 Logout Button PHP example</title>
    </head>
    <body>
        <?php
            require_once 'facebook.php';
            require_once 'faceconn/faceconn.php';
            UseGraphAPI();
        ?>
               
        <form id="form1" >
            <?php
                $logout = new LogoutButton();
                $logout->SetCommandType("button");
                $logout->Render();

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

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

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



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


Configuration

Configuration of the Facebook Logout Button PHP class is done through calls of the setter methods, which in turn set the private properties. For Facebook Logout 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 logout button/link. Default value is 'Login'.
facebook login button php
SetImage
String
Function sets image of logout 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 out.
facebook login button php
SetOnLoginJavaScript
String
Function sets the JavaScript code to be executed after the user is logged out.