Synchronizing Google and Facebook Contacts

Not being a Windows Mobile phone, the G1 obviously does not have any sort of sync capability with Exchange. There are ways to do it using SyncML (Funambol specifically) to link your Exchange and Google account, but I didn't really want to get into that. I ended up using Outlook to export all my contacts into a Windows CSV file and then imported them into Google.

Around 6 months ago, I discovered a tool called Fonebook which lets you import Facebook Contacts into Outlook- with pictures. Those pictures then go through ActiveSync to the phone. Quite handy. The problem when doing a CSV import into Google is that the pictures aren't included.

So I ended up investigating the Google Data API and Facebook Toolkit, and found that it would be relatively easy to create a sync client. Although that wasn't my top priority at the moment, I just wanted my contact pictures on my phone!

I wrote a quick tool that does a one-way sync from Facebook to Google: if a contact is found on both accounts, the Google account gets updated with the image that was found on the Facebook profile. So here you go!

I have no idea if I'll continue further work on this, since it's not a very interesting project; though I'm sure there would be quite a demand for an Android Facebook application...

Here's the source code for the very basic contact picture sync application. I had to tweak/fix the Facebook Toolkit a bit because there were some bugs in it related to the Politicians and Contact Pictures.

55 comments:

Unknown said...
This comment has been removed by the author.
Unknown said...

This, my friend, is exactly what I was looking for - thank you.

And, yes, it was the G1 that spurred on this need.

Unknown said...

thank you. This is really useful

Anonymous said...

I downloaded and had a look, but it didn't work for me.

Is a specific version of dot.NET required?

Do your facebook and google account credentials have to be identical? (I got to the first prompt that asked for login info and couldn't make out which platform it was asking for.)

I'm not asking for support, really... if you ignore this completely, it's not a huge deal. I was mostly just curious.

I do think there is a market for this, however, although I'm not sure how much revenue could really be generated. It might be better as a web service that folks would have to view an ad to use OR pay a small annual fee to get re-sync'd regularly. Maybe.

Good times.

Anonymous said...

Hi!

Really love this ap, this would do so well in the Android MARKETPLACE! However I have one question, what do I need to do to run this on my XP system?

I see a login screen that says Google contacts sync, username and passowrd thn i get this...

See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.IO.FileNotFoundException: Could not load file or assembly 'System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified.
File name: 'System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
at GoogleContactSync.MainForm.mySyncButton_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].



************** Loaded Assemblies **************
mscorlib
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.832 (QFE.050727-8300)
CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
GoogleContactSync
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///C:/Documents%20and%20Settings/Shamela%20Mulahoo/Desktop/GoogleContactSync.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.832 (QFE.050727-8300)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.832 (QFE.050727-8300)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.832 (QFE.050727-8300)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
Google.GData.Contacts
Assembly Version: 1.2.2.0
Win32 Version: 1.2.2.0
CodeBase: file:///C:/Documents%20and%20Settings/Shamela%20Mulahoo/Desktop/Google.GData.Contacts.DLL
----------------------------------------
Facebook
Assembly Version: 1.7.3218.891
Win32 Version: 1.7.0.0
CodeBase: file:///C:/Documents%20and%20Settings/Shamela%20Mulahoo/Desktop/Facebook.DLL
----------------------------------------
Google.GData.Client
Assembly Version: 1.2.2.0
Win32 Version: 1.2.2.0
CodeBase: file:///C:/Documents%20and%20Settings/Shamela%20Mulahoo/Desktop/Google.GData.Client.DLL
----------------------------------------
Google.GData.Extensions
Assembly Version: 1.2.2.0
Win32 Version: 1.2.2.0
CodeBase: file:///C:/Documents%20and%20Settings/Shamela%20Mulahoo/Desktop/Google.GData.Extensions.DLL
----------------------------------------

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.


When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.

Chris said...

I'm also getting the same error as Ujin when I run it through Windows XP. Any thoughts?

Koush said...

You need .Net framework 3.5.

Anonymous said...

Getting the following error message.

See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.IO.FileNotFoundException: Could not load file or assembly 'Google.GData.Contacts, Version=1.2.2.0, Culture=neutral, PublicKeyToken=7e065189dd4b982f' or one of its dependencies. The system cannot find the file specified.
File name: 'Google.GData.Contacts, Version=1.2.2.0, Culture=neutral, PublicKeyToken=7e065189dd4b982f'
at GoogleContactSync.MainForm.mySyncButton_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

Anonymous said...

When I click Sync after entering my facebook information, it says done but it has not synced any pictures

Blake said...

Phenomenal. I had fonebook for outlook syncing, and then to my windows mobile device. Now that google just introduced contact and calendar syncing through exchange I was looking for a program like this. Great job.

T-Will said...

Worked like a charm, thanks!

Locketine said...

it did about 4 of my friends... Their names match perfectly between facebook and google contacts so what gives? Did the program crash after moving just some photos over?

Anonymous said...

Your Application is great!
I'm ready to donate funds to help developing it. It can get much better!
Thanks

Unknown said...

Getting JIT error message as well. I have .Net Framework 3.5 SP1 installed. Does it not work with the SP1 installed?
Argh I was so confident I wouldn't have the same probs, darn jinxed myself.

-----
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.......
----

Unknown said...

I just used your program and the only pictures it synced were for people who I had emails listed for. I was reading your posts (i think) in the XDA forums and you said this is linked to names not the emails, yet the opposite happened. Any advice?

Unknown said...

An update to my previous comment:

I have now noticed that on the G1 all of the people I know on facebook DO have their profile picture being shown. But on my PC, going into gmail contacts it doesnt show the pic unless the contact has an email listed. What is weird is, just to experiment, i tried entering an invalid email for a contact and it still ended up showing the image. Don't know whats up with that, but since it works on the G1, i'm happy. Thanks a lot for making this program.

Unknown said...

Tried it too, Win XP .net 3.5 sp1, gave me the JIT error as well... damn... so close... sad when dev's software looks promising but doesn't work..

Jim said...

Worked pretty great, had to run it three times before it would go through, though... However, many of the photos were kind of stretched out. Thanks a million though, this was a blessing.

Unknown said...

Worked like a charm, thanks!

Anonymous said...

kick ass!!!!!!
I am just done getting rid of outlook in my home setup and "Outsync" (taking pics form FB and putting them into outlook) was the only thing I was missing.
Thanks to you... I don't anymore!

Anonymous said...

To whomever created this application :

Thank You! It worked perfectly, the first time - no errors, no problems. Slick! Well done!

Kevin

Jesse said...

Firstly, great concept!

Does anyone know if this works for Google Apps based email as well, or is the Gmail domain assumed / hard coded into it? I've read instructions on the web which say not to add in the "@gmail.com" bit when filling in the username and passwords fields, but if I'm using Google Apps on mydomain.com and syncing my iPhone calendar / contacts to mydomain.com (rather than gmail.com) what inputs should I use?

Many thanks in advance

Anonymous said...

Who uses Windows??

Marc said...

@Jesse:

Yes it works with google apps.

Jesse said...

Awesome. So it does. I was trying it from work and the firewall must have been blocking it. When I tried it from home, it worked!

Nice one :)

Anonymous said...

Thanks for the app! Used to sync my Facebook contact pictures with my Diamond2.

Works perfectly =)

Jason said...

Worked for me, thank you!

SchWalser said...

Worked for me, thanks! Only contacts it didn't sync were those where the name didn't match exactly. Wouldn't expect it to be able to guess that Ronnie means Veronica or that Christian means Dr. Genes !-)

... said...

Hi,

Thanks for the app and the code.
It didn't work for me at first so I oppened the code and found that if you change the GetRequestUrl of the facebook API code to useSSL = false always, than the sync works !!

Thank you !

Nathaniel Sametz said...

Thanks my friend! :)

Jason said...

Getting an Microsoft Net error now :(

Robert Sinrud said...

Thanks much! Worked like a charm :)

Pierre Masson said...

Wow that worked great thank you! you should package this cleanly and sell it for a few $$!

Anonymous said...

Thank you!!!

Shannon said...

Thank you!!

Test! said...

Getting a .Net error.
"Cannot find object 'widowed'".

T said...

all those who experience problems b/c they only have a @googlemail.com account (not @gmail.com) might want to contact me.
a good friend of mine (1100101) recoded the sync for all of us who were et up w/googlemail instead of just gmail.

all kudoz go to him.

contact me at twitter: www.twitter.com/tokre

Scarica said...

Did any of you guys that were getting the (JIT) error message ever figure out how to make this work? I was so excited about this code and I can't get it to work. I am working on my laptop using Windows Vista, and I downloaded the .NET Framework 3.5 that was recommended, but still no luck. I can't get this thing to work. If anyone has any advice I'd appreciate the help. Thanks!

Anonymous said...

Worked great and FREE...try extracting all files in vista if you get error. Thanks

Gwen Morse said...

Using Windows Vista with DotNet 3.5 and all required/optional windows updates.

Unzip, run .exe file, program starts. Mini window pops up asking for gmail credentials. Enter them and click "sync". Another window pops up briefly indicating facebook login, then closes. Wait a bit, get a "done" box. No sync.

How do I get facebook credentials into the program?

Manuel Martin-Vivaldi said...

It worked fine. Now my HTC Magic with Android 1.6 has the image and info of most of my Facebook contacts

Anonymous said...

Great app. I would love to see a web-based version of this!! :)

Unknown said...

If I was a girl, I'd have your babies for this. Seriously.

I love you.

Jamal Mustafa said...

The clean way: http://jamalpro.freehostia.com/fbphone.htm

h said...

I came with a different approach : do it on a server. If it's any help : http://phaceboogle.bisounours.net/

Unknown said...

Much thanks Koush. Exactly what I was looking for. Most things I find from you are.

Unknown said...

This doesn't seem to be working anymore:

http://pastebin.com/ysirfQFL

Anonymous said...

Was working great a couple of months back, but since (I would assume) the latest facebook update, it's no longer working (see post above).

Gutted, it was a brilliant solution while it worked :(

p_ko said...

Hi, thanks.... I'm starting with the code...

P_kos

p_ko said...

It works... is alive hehehehe...

Great, thanks

Jordan Schulz said...

It says completed successfully, but I don't see any pictures imported. Any logs I can send, something like that?

TJ Allard said...

Is this still working?

XS Labs said...

Hi,

I've re-released this software with a few modifications at http://www.xs.fi/?p=56 , hope it's okay?

Modifications:
- Not needing Microsoft Outlook at the computer where the software is ran
- It did not compile without a few modifications (documented in the link above)

/ XS Labs

Unknown said...

I know it would take longer, but have you tought of matching Gmail and FB contacts using the "mail" fields?

A I can't control my friend's names in FB, there are always matching loses.

IMHO, the best matching technique is Facebook email = any(Gmail mails)

Thank you very much!

Unknown said...

Thanks a lot.
Hope this will work...!! ^^