tags:

views:

576

answers:

4

Is there a Facebook API to add a friend? I can't find one, but then I can't find it stated anywhere that there isn't one, and this seems like something a lot of people would be asking about.

(Note: I'm not talking about a Facebook application, but rather an HTTP-based API.)

Clarification

I should mention that I'm trying to do this WITH the users authorization. They give me their username and password. Not trying to spam anyone.

Twitter has a very simple API for doing this; I'd hoped Facebook did too.

+3  A: 

I do not think there is a way to do this. This is based on user's choice. The best bet would be to have the user pushed to the profile in question and have them do the work.

Edit: You should never ask for a username and password for facebook. that is a violation of the terms of facebook and a poor design choice. you should use their standard api for accessing data to/from facebook.

Daniel A. White
That seems likely - my impression is that Facebook is very careful not to let things be done programmatically on behalf of their users, without explicit authorization.
David Zaslavsky
+1, yeah, yeah, I'm guessing that this would be a security hole. But, then again, there's probably a way to fake it if you were really persistent. (It would also be likely some violation of the usage terms of the site)
altCognito
Thank you for your answer. I AM trying to use their standard API. I would like to add a friend, with their permission. If such an API call exists, it would surely require their name and password, right?
I. J. Kennedy
A: 

There certainly is a way to do this. I have done it. It requires a great deal of screen scraping and also requires an interface to a browser that allows cookies. (Pulling down HTTPRequests won't do this for you)

You'll have to learn about the structure of the pages and create Regexes to find elements you want to interface with.

The way I did it was by setting up an Internet Explorer control on my .NET form and using the interop object model to interface with the control. Some good searches would probably point you in the right direction here.

[Edit] (I don't know of any APIs)

hypoxide
A: 

Check out SimpleTest's scriptable browser. It is part of their test framework, but you can use the browser component independently.

Snoopy is another good option.

Clayton
A: 

Yes, I think we shouldn't ask for user Pass and User name.

But, If you need to do it in your application you can use database/XML to do that. But only your application will treat the added user as a friend not the facebook.

In my application i added all friends in DB and also added my self as a friend of my self. so that i can do the task what is defined to myFriends role(in my application).

ID FBUserId Name

9705 1215966620 Abul Bashar

9706 1248090545 Tuhin Ahmed
9707 1251036547 Orijit Diponkor Shuvrangshu Tridib
9708 1252800907 Shahin Mahmud 9709 1263680515 Binayan Dey 9710 1275860308 Mitu Kumar Debnath 9711 1279017492 Ahmed Riaj 9712 1280150772 Mahbubur Rub Talha 9713 1287414234 প্রবাসী সারোয়ার 9714 1294159220 Md.Humayun Kabir 9715 1294340379 Shah Muhammad Mazed