How do I import Facebook friends from another webs

2020-05-24 20:26发布

问题:

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 don't 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.

回答1:

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.



回答2:

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>


回答3:

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!



回答4:

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



回答5:

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

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



回答6:

Here is an open source PHP 5 tool to let you import contacts from both e-mail and some social networks including Facebook: OpenInviter is an open source PHP class, written in PHP5, for importing contacts from most of the well-known e-mail providers & social networks.



回答7:

Just import them into Yahoo using FB Connect. All better? No screen scraping, no FB violations. Done.