The Admin/Company Facebook_page/ Wall should update when the site admin creates a content, again sharing should be optional where the admin can simply un-tick if he/she doesn’t want to share.
'When I was requested to meet the above objective I remembered Drupal had a module (Post it everywhere') to fulfill, unfortunately it didn't let me to do what I was supposed to do.
After spending some time I came across 'Drupal for Facebook' module which had a special feature to do what I want, but yet it failed to please me, because the configurations were too complicated and did not act as expected. after going through many articles and documentations I found how it works.
Finally I wanted to share and merge everything together as one document. So, here it is ...!
- Drupal 6
- PHP 5 / >
- Drupal for Facebook (containing sub modules) Download here
- Custom module Source
- Facebook-php-sdk Download
- Download the “Drupal for Facebook” module, extract, upload
- eg: sites/all/modules/fb
- Download the facebook/sdk, extract it, rename the folder to ‘facebook-php-sdk’, and place it in the libraries directory
- eg: sites/all/libraries/facebook-php-sdk
- Next go to the modules page ‘admin/build/modules’ and enable the following modules (sub modules comes under the “Drupal for facebook” module)
- Facebook API, Facebook Apps, Facebook Stream, Facebook Connect
- Next navigate to the ‘Facebook applications’ page ‘/admin/build/fb’ or
site building->facebook application.
- and click ‘Add apps’
- Now fill out the fields with the needed information
- Label : a short name for your app (in lowercase)
- Check ‘Enabled’
- Facebook App ID: : Application public key generated by facebook
- Secret: Application secret key
- Check the following image 0.1
- If you don’t have an App, follow the instructions given above the ‘Label’ in the same page ‘/admin/build/fb/fb_app_create/’ to creat one, and add the keys in relevant fields
Create the custom module
- In this module, we prompt the user to publish to their Facebook stream after they perform an action on Drupal (save a node). Because the stream publishing options are relatively complex, we use PHP code to control it. This example comes from fb_example.module, which is included in Drupal for Facebook. You'll find other examples of how to customize behavior there. In your own custom module, you'll want to replace every occurrence of "fb_example" with your module's name.
- Copy & Paste the code from the below given link in your .module file and do not forget to replace every occurrence of "fb_example" with your module's name
- Next click on the tab ’Facebook connect’ admin/build/fb/fb_connect
- and select your app from the ‘Primary Connect Application’ dropdown list\
- then tick the options you want under ‘Theme overrides’ section
NOTE : Facebook connect is an essential component to accomplish our objective
- When Facebook Connect module is enabled it creates a block in admin/build/block so, you will have to locate in in a region in-order to make it visible
- eg: content, footer, header
We are now in our final lap
- Make sure you have logged in as the admin in Drupal.
- and you’ll be able to see the Facebook connect icon in the region you located like the below image.
- Click on it and login with your facebook usernamel, password details.
- Now Click ‘Content management’ and create a content and you’ll be able to see the check-box checked ‘Share on Facebook’.
- And once you hit ‘save’ after filling the fields a facebook window will pop-up requesting you to write something and share it as the following image.
- Trust me you’ve done !!
Have a great time with the module !!!!