Integrate facebook in your site

Here are some steps through which we can integrate facebook in our site using php with zend framework.

Here I am going to discuss on how to integrate facebook in your site using php with zend framework.

For this you have to first register your application in facebook. Please check the following URL
“http://www.facebook.com/developers/”

Here you can set up your application on clicking the “Set Up New App” button in the right top corner of the page.
After setting up your application in the facebook, it will generate Application ID, API Key and App secret keys for the application. These are unique for each application that is registered in the facebook. We will use these in our application.

In second step, download facebook-platform.zip( Facebook Platform PHP5 client ). Please check the following URL
“http://drupal.org/files/issues/facebook-platform.zip”

After downloading the file, unzip it and place the unzip files and folders in the facebook  directory in your public directory of your site. Then define the Application ID, API Key and App secret in the config file of your application.Here is the code in the config.ini file.

;facebook fb.apikey = Your API Key fb.secretkey = Your App secret

fb.appid = Your Application ID

;siteurl
site.url = Your Site URL

After that add a “xd_receiver.htm” file into your public directory. Here is the code for the xd_receiver.htm






In the third step, we are going to create a “FacebookController” in the controllers directory of your application.
Here is the following code for FacebookController.php



In the fourth step, we will create the IndexController.php in the controllers directory. Before creating the IndexController.php add the following javascript in your layout file.



Now check the code for IndexController.php


 

Now in the last step we will create the index view page(index.phtml) for the IndexController. In this page we will show the facebook login button




  
    function RefreshPage(){   
        location.reload();
    }
   
   
   FB_RequireFeatures(["XFBML"], function()
    {
      FB.Facebook.init("", "xd_receiver.htm");
    });


 

        
        
        
            
        



        
        logout
 

Now on clicking the facebook connect, a facebook login popup comes up and after successful login to facebook, application refreshes the page and comes up with facebook logout link. On clicking the logout link, a facebook logout message pops up and and the user automatically gets logout from facebook.

150 150 Burnignorance | Where Minds Meet And Sparks Fly!