Connecting Facebook with Drupal, the easy way.

There are a few heavyweight modules contending to provide Facebook integration for Drupal. Which module is right for you? Simply looking at the Reported installs and Maintenance Status won't present a clear answer.


A recent project of mine required the use of Facebook's OAuth service. Here are the three modules that I considered:


I installed and configured each of these modules before coming to a decision. Here's a quick summary of what I found:

  • Drupal for Facebook
    is still very much in development. It isn't production ready, so if you're not willing to contribute, you may want to cross it off the list. Beyond that, it's important to realize that DFF's strength lies in providing a rough framework for using Drupal to build Facebook Applications. It is not ideal (or intended) for providing polished Facebook features to a pre-existing Drupal site. If you're looking for a good launch pad for some serious Facebook App development, give it a shot-- it may be just what you need. Otherwise, you may want to consider another module.

  • Facebook Connect
    provides a number of unique out-of-the-box Facebook features, like finding Facebook friends on your Drupal site, or publishing a customizable message on their Facebook feed. However, this module is still in beta— it is not in a stable state. It should also be noted that FC uses the Facebook Javascript SDK, which means that you need to be familiar with the SDK if you'd like to extend the module's functionality.

  • Facebook OAuth
    is best described in its author's own words, "This module is built with simplicity and flexibility in mind, it provides login services (and does it well), and an API for performing any other actions you may want to write yourself to query against Facebook's APIs."

The Winner (for me)

After attempting to extend Drupal for Facebook and Facebook Connect, Facebook OAuth was like a breath of fresh air. It's simple and flexible, and best of all, you don't need to learn Facebook's Javascript SDK to use it! Facebook OAuth has a well documented and well designed API that any PHP (particularly Drupal) programmer would be comfortable with. Some key features include:

  • One-click login through Facebook.
  • Automatic import of user e-mail and profile information during initial login.
  • A flexible and direct API for modules to get authenticated and query Facebook's APIs (plus extensive documentation).
  • Does not require any external libraries or downloads.

Harnessing the Power (the fun part)

Before I jump in, take note that you can find detailed information about all of FBOAuth's API functions in fboauth.api.php, which is bundled with the module. And don't forget to read the README.txt!

Now let's run through a quick example of how you can utilize the API.

Facebook OAuth allows you to import values from a user's facebook account and map them to that user's Drupal account during registration. In addition to providing a nice GUI for this mapping, it also allows you to define custom field types and callbacks for accomplishing the mapping and for processing the data. Most popular field types are supported by default.

For my site, I wanted to import a user's facebook address to an addressfield and geocode the location for storage in a geofield. By default, FBOAuth does not support mapping to fields of type addressfield. No problem! We'll use a few handy hooks to add that ability.

First, I want to let FBOAuth know that it can map Facebook location information to fields of type addressfield. I'll use hook_fboauth_user_properties_alter() to do that:

* Implements hook_fboauth_user_properties_alter().
function grasmash_fboauth_user_properties_alter(&$properties) {
// Allow the location property to be mapped to Addressfield typed fields.
$properties['location']['field_types'][] = 'addressfield';

That was easy. Some detail:

  • The first array key 'location' specifies the Facebook source field. Change that to another acceptable value in order to map a different source field to a new field type.
  • You can add as many target 'field_types' as you'd like.
  • For a full list of possible source field values, just take a look at fboauth_user_properties().

Next, let's tell FBOAuth what it should do with data that's been mapped to an addressfield by defining a callback that will process the data.

* Implements hook_fboauth_field_convert_info().
function grasmash_fboauth_field_convert_info_alter(&$convert_info) {
$convert_info += array(
'addressfield' => array(
'label' => t('Address Field'),
'callback' => 'grasmash_fboauth_field_convert_location',

If you're familiar with Drupal's array-heavy architecture, this snippet shouldn't surprise you at all. We're just adding another row to $convert_info. It specifies the name of the function that FBOAuth should look for when dealing with an addressfield. Now let's actually create that function!

* Facebook data conversion function.
* Converts an incoming Facebook location (which is an object) into an array compatible with the addressfield module.
function grasmash_fboauth_field_convert_location($facebook_property_name, $fbuser, $field, $instance) {
$value = NULL;
  if (
$field['type'] == 'addressfield' && isset($fbuser->location) && module_exists('geocoder')) {
$geodata = geocoder('google', $fbuser->location->name);
    foreach (
$geodata->data['geocoder_address_components'] as $key => $components) {
$components->types[0]) {
// Set city.
case 'locality':
$value['locality'] = $components->short_name;
// Set state.
case 'administrative_area_level_1':
$value['administrative_area'] = $components->short_name;
// Set country.
case 'country':
$value['country'] = $components->short_name;

Clearly, this will be completely different for fields of any other type. The example above is specifically tailored for populating addressfield fields, and it relies entirely on the output returned by the geocoder module. If you're looking for some guidance in creating your own callback, just look at some of the default callbacks in, like fboauth_field_convert_text().

The last step is to simply configure which field on the user object FBOAuth should actually import the data to. That is done through FBOAuth's admin page, located at admin/config/people/fboauth.

Other Awesome Things

From the README.txt:
"The Facebook OAuth module provides an API for executing queries against Facebook's vast store of user data." The README.txt goes on to explain the workflow for this process, and how you can write your own custom actions.

I plan to write a subsequent blog post about how you can programmatically execute these custom actions, but that's for another day!


Drupal Version Compatibility: 


Thanks for sharing!


I literally tried Drupal for Facebook and Facebook Connect yesterday and they didn't provide what we required. First time hearing about Facebook OAuth when reading this and just tried it out - BRILLIANT module!

Just what I needed, been struggling with Drupal for Facebook and other similar modules (basically was stuck on external libraries and errors around them). Great to see this straightforward module. Thanks again!

There is an existing wiki over at and I would love to see it get some love to help out the next people facing down this decision.

I have implemented the Facebook OAuth module to my site..On clicking the logout '/user/logout' link user gets logged out of Drupal but on clicking the fb button that user gets logged in.........facebook logins are not asked..which means the user didnot get logged out from fb.... how to do this logout?

Thanks for this article!

I get the mytheme_fboauth_user_properties_alter() function to fire, but using a watchdog() alert, it seems that the mytheme_fboauth_field_convert_info_alter() never seems to execute.

As such it allows me to select the field I want to map, but it never maps it.

Anyone experiencing the same problem?

I'm using Drupal 7.14 with AdressField 7.x-1.0-beta3, with geoPHP 7.x-1.4 and geoCoder 7.x-1.1



Have you tried placing the hook in a module rather than in a theme template.php file?

I have not tried that. Still relatively new to Drupal, but come from a strong programming background... I didn't know that if a hook didn't fire in template.php that it might as a module. Will try to give that a shot.

Thanks for the advice!

I've moved the two functions to a module (and enabled it), but they still don't fire... When in a module, do I need to do anything other than name them correctly?

I'm also looking at your "Part 2" article on importing photos... Using watchdog() alerts I see that the mymodule_fboauth_actions() method fires just fine, and it adds the photo setting in the FBOauth settings area.

But the mymodule_fboauth_field_convert_info_alter() and mymodule_fboauth_field_convert_location() never fire the watchdog() alert, nor do I ever see it change my user data.

...thought... If my user account was already created, and then I connect it to FB, does the xxxx_field_convert_info_alter() still apply... or is it just for new accounts?

Sorry for the questions. I actually got this working now. Had an issue with one of my functions having a typo in the name... I think it went unnoticed because I was using a pre-existing account, but when I tried a clean user never having been on the site, it worked like a charm!

Working on something for hours, only realize that you made a typo. I've been there.

Hi madmatter23!

Thanks for sharing this -- it's been incredibly useful. I'm trying to do the same type of integration you did with addressfield with Name Field, but I'm missing a bit of a step. One of your code comment reads "Converts an incoming Facebook location (which is an object) into an **array compatible with the addressfield module**." If you have a moment, would you explain where one would look to find the array format necessary for a field type defined in another contrib module (say, for example


First, I created a new node using the field in question. Then, I used the devel module to look at the node's properties. That reveals the structure of each field. If you need to quickly recreate the array structure in php, devel's dvm() function is a great improvement to print_r().

Nice tutorial. Is there any way to open fb-login window separately.

Thanks for the tutorial. This is one of the issue I haven't touched yet seriously. I didn't expect that it is easy :)

Hi there!
Thanks for a so very much needed explanation of these modules!!
I didn´t understand something though: May I use FB OAuth to let anonymous users (ie. comment) logging in in their FB account but without creating an account in the Drupal site?

I implemented the facebook OAuth module to my current project. I get it some error after installing this module..On clicking the logout '/user/logout' link user gets logged out of Drupal but on clicking the fb button that user gets logged in.

Can You share with me a complete video for Facebook Integration In MY site PLz

can you share your custom module?

You forgot to mention where to put these codes.

Can I use FB Oauth to allow logins (and registration, I suppose) from facebook but limit registration/login to a particular facebook 'group'?
I an running several Drupal installations and have written a few bits of PHP. Any help would be greatly appreciated.

I tried a lot to connect the Drupal with my Facebook page. But the message always showed is access denied. What should I do? I tried the code that you provided here it is working partially. However, I think it is my fault.

Been looking for this , thanx !!

Very usefull, I always want to visit this site every day and comment your post. But I can't. Thanks for sharing.

Hi,it great feeling to read your article its very help full to me, Just need to ask you Facebook OAuth work fine with HybridAuth module?I am using HybridAuth module to login with social site. but i need location of user.

I configured FB_connect and FbAuth also write a code into custom module rather then on theme. and implement fb_loc_fboauth_user_properties_alter(&$properties) hook and print_r($properties). Whenever i tried signup or login with FB it prints me an array but unfortunately it empty. so please help me out how do I fetch location of user from FB.

Supplying statue: Put this sculpture having percolate wrapper. Almost all of the statues are usually peculiar healthy. Consequently, it is best to help keep these individuals within frequent carton.

Packers and Movers Mumbai or
Packers and Movers Bangalore or
Packers and Movers Hyderabad or
Packers and Movers Gurgaon

Position your sculpture at the heart on the program. The real position must be essential to be able that sculpture doesn't feel almost any retaining wall from those.

Packers and Movers Chennai @
Packers and Movers Delhi or
Packers and Movers in Pune or

Packers and Movers Delhi @
Packers and Movers Noida @
Packers and Movers Faridabad @
Packers and Movers Ghaziabad @
Packers and Movers in Gurgaon @
Packers and Movers in Mumbai @
Packers and Movers in Pune @

List 5th Packers and Movers in India

Unloading, unpacking and rearranging of home stuff. Due to certain agonizing concerns shifting residence can make your awfully exhausted and burdened. So it would be a great decision to make use of services of one of correct, competent and well-qualified packers movers agencies in order to simplify the complete relocating process and transform the state of affairs into easygoing and simple affair.

Unloading, unpacking and rearranging of home stuff. Due to certain agonizing concerns shifting residence can make your awfully exhausted and burdened. So it would be a great decision to make use of services of one of correct, competent and well-qualified packers movers agencies in order to simplify the complete relocating process and transform the state of affairs into easygoing and simple affair.

text loans @ | same day loans no credit check
quick loans @
quick loans @
doorstep loans @
same day quick loan @
12 month loans @

To acquire 12 month payday loans the borrower is required to get register with For this process you need to complete a simple formality by filling application form.
This is very easy and can take just few minute to get completed. The essential details regarding your address, contact, employment status, income detail, the amount to be loaned etc should be mention honestly at
Fast Payday Loans
Quick Online Payday

At, obtaining payday loans is a very simple job. Also, even bad credit borrowers can without intricacy find the money very speedily without hassles at

Any personal necessities like learning expenses, health requirements, family requirements, wedding expenses, travel requirements, etc can be easily satisfied with personal loans at

Online business loans

Find an obligation-free quote from our specialist team and make a decision the most excellent option for your need Up to $1,000 depending on the lender at
Cash Loans

Thanks for all your information, Website is very nice and informative content.
Packers and Movers Delhi @
Packers and Movers Gurgaon @
Packers and Movers Noida @
Packers and Movers Thane @
Packers and Movers Navi Mumbai @

Thanks for Nice and Informative Post. This article is really contains lot more information about This Topic. -
Packers and Movers Hyderabad @
Packers and Movers Bangalore @
Packers and Movers Mumbai @
Packers and Movers Chennai @
Packers and Movers Pune @

Furthermore, these finances are for sale to all sorts involving consumer due to the fact are all dealt with below identical. No matter whether, you might be any non-homeowner or maybe a renter, poor credit holder or maybe very good banker, everybody is made welcome within these finances due to the fact not there is certainly credit evaluate or collateral distribution.

Pay loans are useful for the common people and the middle class, who are independent to take. Loans at very low interest rates are widely available, which are easily accessible to all. Online payday loans made it very easy to apply and treat faster and easier. There are many financial companies that are online on the Internet, on-line transactions will provide. These companies offer payday loans, if the customer be the last months bank statement for society as a proof of his day loans income.Pay a complete rescue when a certain amount required in an emergency situation. Payday loans are a blessing in disguise, if the amount is refunded to the Company during the period. On the other hand, if the amount back in time to pay off, he can break these nerves with the amount of the fine plus interest and costs.

Top 5 Packers and Movers Pune or
Top 5 Packers and Movers Bangalore or
Top 5 Packers and Movers Gurgaon or
Top 5 Packers and Movers Mumbai or
Top 5 Packers and Movers Delhi or
Top 5 Packers and Movers Noida or
Top 5 Packers and Movers or

Nice comments

Inside ease involving types home, the guy can make an application for financial products any time this individual discovers themself in need of income. 1 understands that they can't use continuously coming from pals in addition to family members. unemployed loans
,fast cash loans

Inside ease involving types home, the guy can make an application for financial products any time this individual discovers themself in need of income. 1 understands that they can't use continuously coming from pals in addition to family members. unemployed loans
,fast cash loans


Good post. Thank you for sharing...

Cash via Text @
Text Loans @
Same Day Loan @
Text Loans @
100 Text Loans @
Text Loans @

Thanks for all your information.Website is very nice and informative content.

this is one of the website

Thanks for post this helpful post - Please visit for More information about -
Packers and Movers in Hyderabad @
Packers and Movers in Pune @
Packers and Movers in Mumbai @
Packers and Movers in Chennai @

This article is really fantastic and thanks for sharing the valuable post.
Packers and Movers in Delhi @
Packers and Movers in Bangalore @
Packers and Movers in Gurgaon @

From the perspective of the borrower are 100 days payday loans same day is always a welcome decision that he / she is able to make in their lives and bring a phenomenal change. These special loans are designed in such a way that the prospective borrower is benefits from them. In most cases, these loans are easy and well worth considering. To get borrowers Instant Cash - The best thing about 100 days payday loans is the same day that this type of special loans immediately and without waiting for verification sanctum bonier. - A professional Web Design Company India provides affordable Web designing and Website Development in India.

Within 24 hours of approval of 3 month payday loans amount can be transferred to the borrower's account. Since that day no fax is as fast, without the hassle of paperwork processing, get borrower immediate access to cash, then you can this amount can with any financial emergency to cope with requirements of the borrower.

You just need to top off your own points of interest, for example, name, age, living arrangement and office location, organization name or business' name and your month to month pay and so on in the online structure alongside the sum you need as an advance. So top off this structure and get cash inside of 24 hours. Despite the fact that you can get a credit inside of 24 hours, there are a couple conditions which you must need to satisfy. These conditions need you to be a UK subject, at least18 years old or above.

When working on this task, you will find that you are limited in the amount to be lent to you by any provider. This can be a limit imposed by the lender based on your ability to repay or even because you borrow for the first time. In other cases, it may be the maximum they are allowed to pay a single person. Starting the process of getting the money you need is easy. You will simply need to complete an application, provide the necessary documents or information and the lender will process the request. According to the factors mentioned above, you will qualify for a specific amount.

Add new comment

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.