This has been a big topic since FB has changed their TOS to allow for extended permissions to be saved IF and only the user authorized your app.. When they authorize your app they will now see all the various extended permissions your asking for.
the key idea to syncing accounts between drupal and fb is to be able to get these extended permissions data. A patch was created to add the extended permissions to the FB app module and can be found here. http://drupal.org/node/867242
What is missing is the ability to extend the drupal profile fields to capture this data if authorized and remove them when the user removes the app (I think thats part of the TOS as well)
something like profile_hometown for example would store the home town data from FB into drupal..
I would be willing to work with some people to put something together and have looked over the loop where it stores the users email and username... but I have limited time right now, however I figured I would capture this request since its a pretty requested feature for Durpal FaceBook module
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | mapping.png | 13.57 KB | Anclywen |
| #6 | change_data.png | 15.03 KB | Anclywen |
| #6 | remove_profile.png | 40.03 KB | Anclywen |
| #6 | check_profile.png | 40.62 KB | Anclywen |
| #3 | fb-drupal-permissions.jpg | 84.21 KB | gateway69 |
Comments
Comment #1
Anclywen commentedField storage:
Maybe instead of the profile module, we will use Content profile module
I do not like the profile, it hurts me, lack of imagefield and filefield.
But the combined power of CCK & Views, when you can handle files, not mention to using with other content types (Views).
Synchronization:
In order not to quarrel, it seems to me that it would be better to leave at administrator's discretion.
In some cases just once an hour, some every 3 minutes.
Unfortunately, you can't use Cron, because in most cases we need to make synchronization when user is not using your application (or application must have permission offline_access)
Comment #2
Dave Cohen commentedI agree this is a great feature to have! I haven't tried to implement anything along these lines, in part because it was originally a violation of facebook's terms of service. I also see it as pretty complicated. For example, should values only be copied from facebook, or synced (two-way)? How does one map a value from facebook to a profile field (i.e. does the drupal field have to have exactly the same name used on facebook?)
If you want to build a module to work specifically with one third-party module, like Content Profile Module, or CCK, I welcome that but I think it should be done as it's own standalone module. That is, not part of modules/fb, but use modules/fb as a dependency.
If you want to build a module that works more generically, supporting drupal's core profile module or using drupal_execute() to save the values regardless of how they are stored on Drupal, then I would consider adding it to modules/fb (or possibly modules/fb/contrib).
Either way I'll do my best to help, but don't at the moment have any real time to work on this myself.
Comment #3
gateway69 commentedI figured I would take a bit of time to map out some thoughts (check included image) on how this could work and be flexible enough for people who want to use drupal profile or other.
I think one of the issues at hand is some might want to use default profile and other content profile or even a custom cck type, which I think is valid, I for one am using Advance Profile Kit on a few of my sites but use regular drupal profile on others.
with that said I think it might be solved by using the extended permissions names from the FB side of thigns.. like for example:
user_location
user_photo
User_relationships
and defining what those are for example
user location --> cck field location , or just a normal text field (location field might be to advanced for now)
user_photo --> image-field
user_relationships --> text field
Of course to keep it simple it might be valid to only use maybe the default cck types that come with cck and maybe image-field
Then on the drupal admin side of things we have a separate tab called extended permissions. which allows you to create a new one lets say App Test123, then I select the permissions I want to enable, time to sync (keep things in sync) and a pull down of drupal profile or content profile...
by selecting one of the proper defined fields (which needs to be defined first for all permissions) get inserted into content types..
Then save.. .now when I create a new app, I can instead of having permissions their select from a pull down of created permissions from the other admin section...
on the user side of things, they should be able to remove the app, remove all permissions, or even go down to having the ability to just turn or uncheck home_town which then removes this from the drupal profile..
anyhow easier said than done but just some thoughts.. mind map included ...
Comment #4
Anclywen commentedNext idea:
It seems to me that we need an API that will be was between Facebook and other contributed modules.
API will be responsible for:
- Cyclic retrieval of data from facebook (and then calling hook_fb_synchronisation_check_field )
- Changing data on facebook (API function called by other modules)
- A invoke to remove all data (hook_fb_synchronisation_remove_all_fields() ) or specific fields
- check required permissions
At first glance, we need to create: //function names are examples, probably will be changed
Mapping fields:
Mapping fields is done directly in the module. You can get all available fb's fields via fb_sychronisation_get_fields($app_id)
Synchronisation:
API invoke hook_fb_synchronisation_check_field($uid, $field_name, $value), and the contributed modules update the value (if necessary)
Module call fb_synchronisation_change_field($uid, $field_name, $value) and can update field in the FB
Removing data:
On demand, API should invoke hook_fb_synchronisation_remove_all_fields() or hook_fb_synchronisation_remove_field($field_name)
Advantages Solutions:
Fields can be saved in any way (Profile, CCK, etc.) (by creating standalone module)
Mapping and maintenance depends on contributed module.
What we need:
Name and describe every field in the FB, together with its type (text, int image, array (text))
Eg.
Standalone or fb/contrib
As Dave suggests, I'll create CCK integration as standalone module.
I'm not sure, which is better, profile integration as standalone module or in fb/contrib (after all it's a core module)
--
A bit much, but I hope is quite clear :)
Comment #5
gateway69 commentednice.. sounds like some attack plans are made.. :)
Comment #6
Anclywen commentedBecause picture is worth thousand words (and my English is a bit rusty :) ), some battle maps
Comment #7
Anclywen commentedI've found something really interesting - FB Real-time Updates
Of course it have some limitations:
List of user connections to which you can subscribe:
You can't subscribe to these user connections yet:
And ...
Comment #8
gateway69 commentedany movement on this, I'm holding off on FB module for now since I just cant get it to do what I need for a new game we are working on, I'm in the process of writing some custom code that will when a user on FB auths the app, ill write the FB data to the drupal custom profile with the data that im requesting from FB.. the only issue I'm facing right now is when FB user doesnt have a drupal account how do i create one on the fly and assign or link it to the custom profile?
Comment #9
Dave Cohen commentedTake a look at fb_user.module. It creates a drupal account, links it using the authmap table. It even invokes hook_fb after creating the account so you could put your code in that hook.
At some point, I'm planning to use a new table instead of authmap. But for now at least, authmap is where the local account is linked to the facebook account.
Comment #10
gateway69 commentedthanks ill give that a shot, what would be the minimum install for the facebook drupal i would need, i guess i mean the which modules do i need. So far I created a content profile type with the permissions and extended permissions data i want to store, when the user hits the page and allows, i want wanted to do a db insert into that table with all the fb data, I guess then your saying I could use the fb_user.module to create an account for that person also?
Comment #11
RasputinJones commentedActually wrote this yesterday. Updates content profile fields with data from fb retrieved using FQL. This isn't production ready but thought I should share...
Comment #12
Dave Cohen commentedI think you're better off using hook_form_alter() to pre-populate the default values.
Also, you shouldn't name your module "fb_module" because "fb_..." is essentially reserved by modules/fb. I recommend "custom_fb" or "mysite_fb".
Comment #13
gateway69 commentedwow sweet.. we should get this incorporated into the FB module or a separate plugin..
ST
Comment #14
RasputinJones commentedDave thanks for the feedback. The reason I used after build was because these were CCK fields in Content Profile. It's very hard to update these in hook_form_alter.
The module's actual names is mysite_fb. I just took off identifying information...:)
Comment #15
gateway69 commentedi did something a bit different.. its outside of the fb drupal module since im doing most coding by scratch for our game, but if you pass in a fb uid and app id, you can save data to the content profile module.. Probably not the best way to do this since im still learning the drupal api system.
ST
Comment #16
g.k commentedsubscribing
Comment #17
westis commentedsubscribing
Comment #18
ceriamy commenteddrupal for facebook has been nicely installed and all modules seems to give me no problem. But I'm confused about what else to be done, there is nothing appearing in my drupal site, no Facebook Log-in icons, no Facebook connect icons, no "like" icon in my drupal site. The installation document stops at completing installation, but then what? What should be done after that?
Comment #19
Dave Cohen commentedComment #20
g.k commentedI'm also learning the Drupal APIs. Can you please provide some information on where you added the function and how to call the function I would like to pull the data from Facebook and update content profile during initial registration and if possible, during linking of user's local account (already registered used) through Facebook connect.
Comment #21
ckngHere are some thoughts on mapping the data without putting restriction on certain modules. Well, except one, the Rules module, optionally if only user need to get more FB data. The only need is to create FB events when it happens and we can conveniently tap into Rules existing facility to validate, populate fields (including CCK), update the node, etc.
These events can be triggered when user connect with FB, on demand or using FB real-time.
#907706: Rules module integration, we probably only need the following events
- fb_user_connected = User has connected his FB account
- fb_user_disconnected = User has disconnected his FB account
- fb_user_login = User has logged in via FB
and some sample rules..
Comment #22
gorgo commentedsubscribing
Comment #23
bunker commented++subscribing :-)
Comment #24
monicadearsubscribing - I'd like to work on integrating Facebook with Advanced Profile Kit.
Comment #25
Bobuido commentedGood idea. Subscribing.
Comment #26
c0m4 commentedComment #27
c0m4 commentedsubscribing
Comment #28
rumblewand commentedsubscribing
Comment #29
vlad.k commentedsubscribing
Comment #30
stieglitz commentedsubscribing
Comment #31
jjjames commentedfollowing
Comment #32
pribeh commentedsubscribing.
Comment #33
FergalMohan commentedsubscribing.
Comment #34
zabelc commentedSince my users only keep their Facebook profiles up to date this would be a fantastic feature. Did any of the thoughts from last October come to any results?
Comment #35
johnla commentedsubscribing..
I'll share if I get anywhere.. Thanks for sharing your progress, fellas
Comment #36
escore commentedIf anyone has more time than me, here's how I've been thinking about cutting and pasting it (nothing has been tested):
All of the above is paper programming, not code that has actually run. Unfortunately, I know nothing about how to best call user_save, given that there are account settings, profile settings, profile categories etc. If you get this code (or something like it) to work, please post the result.
Comment #37
Dave Cohen commentedI've been pretty silent on this thread because I see this as a problem best solved by custom code. Drupal has so many ways of storing data with users (the $user->data, profile module, fields, profile nodes,...) and facebook has so much different data, depending on which extended perms are granted. So I don't expect a one-size-fits-all, click to configure kind of solution to work for many people. Of course I could be wrong so I like to see snippets from anyone that has anything working.
Regarding #36... I think better to implement the FB_USER_OP_PRE_USER operation. This is invoked before the fb_user.module creates a user. That is, throw some values into the &$return parameter of hook_fb_user, and those values will be passed into user_save() when fb_user.module calls it. That hook gives you a change to change a user's name or anything else about them before the account is created.
Comment #38
ranx commentedSubscribing.
Comment #39
bcgarland commentedsubscribing
Comment #40
jcarrig commentedsubscribing.
Comment #41
escore commentedSo I finally got around to doing something smallish with this. The following code will set the user account's language using the language set in Facebook when creating a new account. Replace "mymodule" for your own module name to make it work.
Comment #42
rumblewand commentedGood progress is good. Thanks for your work!
Comment #43
technikh commentedsubscribingg
Comment #44
bjalford commentedDoes anyone have an example of code to get content, say gender, into a field?
Comment #45
NickWebman commentedsubscribing. this is huge.
Comment #46
kandalam commentedsubscribing...
This seems very interesting. Harnessing the power of facebook in drupal sites.
Comment #47
wrathfulsquirrel commentedAlso subscribing.
Let me ask guys. I am trying to figure out how to connect a new profile created by clicking "Connect with Facebook" button with user's FB email address (it doesn't show in the drupal "users" table). Anyone know how to do that or where to code?
Comment #48
kevinquillen commentedThe RPX module is able to do this for either core user Profile or Content Profile modules.
Comment #49
wrathfulsquirrel commentedThanks. I would check this out and leave a short information does it work accurately.
Comment #50
wrathfulsquirrel commentedIt seems that Janrain Engage doesn't wrok as I wanted:
1. the bridge between Janrain Engage and Content Profile doesn't exist,
2. also there is not any "Connect with" button as I described in the Drupal for Facebook case: http://drupal.org/node/1181834.
Comment #51
rollingnet commentedand
I tried for several days to figure out in which way, during registration, save for example "birthday" or "list of friends" fields from facebook to the same standard profile fields on Drupal, but without any success.
Can you show us a working snippet for that? (I'm using 7.x-3.x version)
I think saving data from facebook's account with ease were one of the missing feature of your promising module.
Thanks in advance
Comment #52
Guntas commentedHi all, I am looking for the patch or code which I can use to simply update the profile name and picture with facebook name and picture. I am presently using fb module.
Please help
Thanks
Comment #53
agileadamThank you RasputinJones! Some of your code helped me a lot.
In a hook_form_alter:
Comment #54
skolesnyk commentedGuys, is there any progress on syncing Content Profile fields to Facebook user profile fields?
Comment #55
Dave Cohen commentedfb_user.module will call hook_fb_user() before calling user_save. So, your module a chance to add data that will be passed to user_save(). The profile module will honor that data, if you get the field names just right.
The example code below is for D6, and works if you've named your profile fields "profile_name_first" and "profile_name_last". In D7, it works in principle the same way, but the data structure has become wildly more complicated.
Now if someone wants to make a module that makes this stuff configurable. I.e. when editing a profile fields, add an option "grab this data from facebook". That would be cool!
Comment #56
Frederic wbase commentedFor drupal 7 i can fill custom user fields like this:
Only one problem, only the first letter is saved :s
grts
frederic
Comment #57
kevinquillen commentedAren't you missing the value item?
$return['field_fieldname']['und'][0]['value']Comment #58
Frederic wbase commentedOf course! How Stupid of me! Thanks for your quick reply, it works like a charm now!
Maybe we should post this example in the documentation section. I think there are a lots of people searching for this one.
Comment #59
kevinquillen commentedAlso... to do this you need to know what those fields are. It won't always be 'value'. For some fields, it might be URL, email, etc, some fields are different.
Comment #60
Frederic wbase commented@kevinquillen yes i know... I have worked many times with those things... Its just that i was trying so hard to get this thing working with the fb module that i overlooked this ;-)
Comment #61
lazly commentedSubscribe! :)
Otherwise I have a problem with this solution, concrete with the hometown information. If i debug my hook with dpm() then I cant find this data tag: $data['info']['location']['name'] Its missing. :( The interesting part is that I got this permission from FB, and if I click to the profile page after login with an admin, where the module dump out the FB params, there I see it. Anybody has any idea? :) Thanks!
Comment #62
Dave Cohen commentedHow do you get the data you're passing to dpm?
The piece on the user profile comes from fb_devel.module. It does not call fb_graph(), but instead:
As you may know, not all users make that info available. You can also try facebook's graph explorer to see what's there.
Comment #63
lazly commentedHi! Thanks the answer.
My module:
And here I cant find the data in the $data array, but if I check the http://mysite.com/user/$uid page there I can read this:
Has you got any idea about this problem? Thanks! Lazly
Comment #64
Dave Cohen commentedThere's a convoluted history behind the $info passed to that hook. It used to come from a facebook api called users_getInfo(). They deprecated that, so the code switched to use something called FQL. It still uses that, but the devel info you're seeing on user/$uid comes from a new thing called the graph API.
There are a couple possible fixes for this....
a) it might be possible to add location fields to fb_users_getInfo(). You'd have to look up exactly what's available to FQL.
b) fb_users_getInfo() could be changed to use the graph query. This is a bigger change, probably not worth doing until the next major release of modules/fb.
And finally this is probably your best bet for an immediate workaround:
In your own hook, call something like:
That $more_info array should end up being the same data you see on the user page.
Comment #65
lazly commentedHi!
Unfortunately the fb_graph isnt worked for me correctly, because that want an second parameter, but I copy out the source of fb_devel_user_view function (you can find it in fb_devel module), and rewrite it. Its was successful, my module currently looks like this, and its working:
Comment #66
miguered commentedsubscribing! :D