tags:

views:

7146

answers:

10

I am looking for a way to connect to facebook by allowing the user to enter in their username and password and have our app connect to their account and get their contacts so that they can invite them to join their group on our site. I have written a facebook app before, but this is not an app as much as it is a connector so that they can invite all their friends or just some to the site we are working on.

I have seen several other sites do this and also connect to Yahoo, Gmail and Hotmail contacts. I dont think they are using Facebook Connect to do this since it is so new, but they may be.

Any solution in any language is fine as I can port whatever example to use C#. I cannot find anything specifically on Google or Facebook to address this specific problem. Any help is appreciated.

I saw a first answer get removed that had suggested i might need to scrape the friends page. The more I look around, this might be what i need to do. Any other way i think will require the person to add it as an app. I am wondering how a answer can get removed, maybe that user deleted it.

+2  A: 

Seems like Facebook has an api for this. Check this blog here.

http://developers.facebook.com/news.php?blog=1&story=73

Coda
It requires an app key so the user still might have to accept it as an app. I am definitely going to look into it. It looks cool to use JavaScript instead of server side.
Jim Zimmerman
+9  A: 

Not answering the question but hopefully providing some insight...

It's features like this that teach people that it is ok to enter their username and password for site A on a form from site B. This is most definitely not ok. Please do not make people think it is.

But maybe the Facebook API allows you to circumvent this problem, by making people log into Facebook itself to give your app access. A slight but important difference.

Thomas
+3  A: 

I looked up that it is alright to answer my own post, so here it is.

It turns out that you will have to scrape the friends list which is not legal in facebook terms of use. So we will not be doing this for our sites. Here are a few articles that show what happens when you don't play by the rules. Plaxo tested their scraping with Scoble and Facebook shut down Scobles account in January of this year.

http://scobleizer.com/2008/01/03/what-i-was-using-to-hit-facebook/

http://news.cnet.com/8301-13577_3-9839474-36.html

Jim Zimmerman
facebook is run by jerks then...they'll happily scrape a dozen different sites to import friends, (using the shady method where you have to trust facebook with your password) but you try to scrape from them and they shut you down?
davr
They should discourage it, as they want the freedom to change their layout, which would break your scraper. using their API's gives a better chance of keeping it working for a longer time.
Karl
@Karl: Assuming their API allows you to do what you want... they just want to control your shit. They only let you touch stuff so long as it brings them more traffic.
Mark
+1  A: 

Here is an open source PHP 5 tool to let you import contacts from both e-mail and some social networks including Facebook.

[http://www.webresourcesdepot.com/openinviter-open-source-contact-importer-from-e-mail-providers-social-networks/][1]

[1]: http://OpenInviter is an open source PHP class, written in PHP5, for importing contacts from most of the well-known e-mail providers & social networks.

jtyost2
A: 

Well, I stumbled upon this post and then I stumbled upon this http://openinviter.com/index.php

Anyone who later looks this topic up on stack overflow might like to know about the Open Inviter. Its pretty awesome!

Boushley
Its good, buts heavily using screen scraping.. lots of chances of failiure in a CSS change.
Mohit Nanda
True. Once I took a closer look at it, I realized how much it relies on screen scraping. But hey what are you gonna do. Works fairly good right now, and is written well enough that you could pretty easily change if the site changes.
Boushley
+3  A: 

I asked this question awhile ago and before facebook connect was live and well. The best way to really do this is using facebook connect.

http://developers.facebook.com/connect.php?tab=website

I am currently using this on our live site and using the Facebook Developer Toolkit for .NET on Codeplex here:

http://www.codeplex.com/FacebookToolkit

Good luck!

Jim Zimmerman
+4  A: 

You can use Facebook Connect 'Account Linking'.

Python/Django example from Facebook developers wiki:

Page:

def invite_friends(request): 
    #HTML escape function for invitation content. 
    from cgi import escape 
    facebook_uid = request.facebook.uid 

    # Convert the array of friends into a comma-delimeted string. 
    exclude_ids = ",".join([str(a) for a in request.facebook.friends.getAppUsers()]) 

    # Prepare the invitation text that all invited users will receive. 
    content = """<fb:name uid="%s" firstnameonly="true" shownetwork="false"/>    wants to invite you to play Online board games, <fb:req-choice url="%s" label="Put Online Gaming and Video Chat on your profile!"/>""" % (facebook_uid, request.facebook.get_add_url()) 

    invitation_content = escape(content, True) 
    return render_to_response('facebook/invite_friends.fbml',
      {'content': invitation_content, 'exclude_ids': exclude_ids })

Template:

<fb:request-form action="http://apps.facebook.com/livevideochat/?skipped=1"     
     method="POST" invite="true" type="Online Games" 
     content="{{ content }}">   

    <fb:multi-friend-selector max="20" 
     actiontext="Here are your friends who aren't using Online Games and Live Video Chat. Invite them to play Games Online today!" 
     showborder="true" rows="5" exclude_ids="{{ exclude_ids }}"> </fb:request-form>
Jon Hadley
A: 

Openinviter no more works for Facebook, Youtube, Myspace, twitter etc. However, it works for others like Gmail, LinkedIn, Orkut etc.

jay
A: 

I confirm that the facebook plugin on openinviter doesnt work. It fails trying to find the user id (because now there is an Alias of the user). Sometimes you get, because of that, the friends from other person (related to you). There is also an encoding problem, since there is no json decoding of the retrieved data.

Rodrigo
A: 

Hi,

I have recently blogged a couple of articles when I was learning facebook connect;

http://www.lordyz.co.uk/tag/facebook-connect/

Hope you find them useful. Please leave comments and follow me on twitter (chrislord) if you do.

Cheers

Chris

Chris Lord