tags:

views:

135

answers:

5

Hello,

Twitter and Facebook invite new users to send an invitation to everyone in their Gmail, Hotmail, or Yahoo Mail accounts.

Is it easy to add this functionality to a website?

Thanks,

John

+2  A: 

Last I checked you basically have to pretend to be a web browser then programatically log in to the site, scrape the contacts, then compose/send the message. It isn't difficult, but it is time consuming as each of these services works differently.

I does, however, look like people have written script for some of this though: example.

fiXedd
A: 

Yes! What they generally do is to send in the email a special URL that contain a code, for example:

www.mysite.com?UserCode=ABC

That code (ABC) is associated to the email of the user so the application undestand which user is trying to subscribe. You must keep in a database the pair: email, code.

HTH

ema
+1  A: 

i see free script

http://sourceforge.net/projects/contactgrabber/

Haim Evgi
A: 

All of the above answers are correct, here is a summary and some more explanation:

  • You first need to get the user's login for each service you want to get contacts from (I personally don't understand why people would do that - I would never give my GMail password to Facebook, let along some little known web site).
  • Then you can simulate a login to the said website and grab their contact list as an export (all serious email services allow you to export the contact list as CSV or something). You can implement this yourself or use some external library such as contactgrabber mentioned by Haim.
  • You then go over their list of contacts and for each contact you generate a key (you want to generate a unique key for each email you send so you'd know who responded to you). Generating the keys is easy - take some info like the current user's email plus the target email address, add the current time and pass everything to a hashing function like SHA1 - should do the trick.
  • Now store in a database table for each contact you got: the inviting user's ID, the email address being invited and the key you generated.
  • Lastly send a nice email to each contact with a URL to your website's "invitation activation page" with the correct key applied - like so: http://www.somesite.com/invited?key=123456780abcdefgh

when that page is accessed, get the key from the URL and find it in the table - that would give you the email address that activated the invite and the user that invited them. From here you can take it to where ever you want.

Guss
Thanks... by "login" I assume you mean "password"? I was wondering if Facebook and Twitter require the user's email password for this process. I agree with you... I would never even give Facebook or Twitter my email passwords.
John
Yes, indeed so. When you you go to "invite" in Facebook, it asks for your email and password. From the email address they infer which service you are using and what is the login for that service, and then they log in in your name to get the contacts. You can also accept a contact list in CSV or vCard format so people will not need to give out their email passwords.
Guss
A: 

Please are you saying i can obtain a users' contact list without requesting for their password?

I need this feature in my site and i would prefer not to ask users for their passwords.

Taller