Drupal for Facebook
1.Download Drupal for Facebook Module. And place into sites/all/modules folder.
2.Download Facebook-PHP-SDK library and place into sites/all/libraries folder. Folder should be facebook-php-sdk.
3.In settings.php files, you have to add the following lines,
1.include "sites/all/modules/fb/fb_url_rewrite.inc";
2.include "sites/all/modules/fb/fb_settings.inc";
3.$conf['fb_api_file'] = 'sites/all/libraries/facebook-php-sdk/src/facebook.php';
4.Then enable the following module
1.fb.module
2.fb_app.module
3.fb_connect.module
4.fb_user.module
5.Goto admin/reports/status page and verify the Facebook PHP SDK loaded or not.
6.Then you have to generate the API/Secret key in facebook for your site.
1.App Display Name - Your application display name – Human readable without space
2.App Namespace: Your namespace of your domain (All letters are small)
3.Contact Email – Your Email id
4.Category – Other
5.Website – Site URL – http://www.domain/com
7.Go to admin/build/fb page and configure the Application for Facebook API settings.
8.You have add the following attribute in your html tag: xmlns:fb="http://www.facebook.com/2008/fbml"
Login Button Interface
=================
Manual
---------
$_fb_app = fb_invoke(FB_OP_CURRENT_APP);
$facebook = new Facebook(array(
'appId' => $_fb_app->apikey,
'secret' => $_fb_app->secret,
'cookie' => true,
));
$loginUrl = $facebook->getLoginUrl();
global $base_url;
$params = array( 'next' => $base_url . '/' ); // Custom redirection after logout link press
$logoutUrl = $facebook->getLogoutUrl($params);
?>
Or Drupal Theme
print theme('fb_login_button', t('Connect with Facebook'), array('attributes' => array('size' => 'large', 'background' => 'dark', 'onclick' => 'removePopup();')));
Or FML Tag
<fb:login-button>Connect with Facebook < /fb:login-button>
Or Javascript
<a href=”javascript: doLogin();” > Connect with Facebook < /a>
JS:
doLogin();
function doLogin() {
FB.login(function(response) {
if (response.session) {
FB.api('/me', function(response) {
//alert('User: ' + response.name);
//alert('Full details: ' + JSON.stringify(response));
}
);
}
} , {perms:''});
}
Required Versions:
==============
Drupal 6.x
DFF - 6.x-3.0-beta1
facebook-php-sdk - Facebook PHP SDK (v.3.1.1)
Issues in DFF and Drupal
===================
Whereever they using getSession() function inside fb module folder, we have to repalce getUser() function. Because getSession() is not exist in Facebook PHP SDK kit.