rptwsthi
rptwsthi

Reputation: 10182

How to send add friend request (to facebook user) from iOS application?

I know there are lot of questions on this topic but none of those have satisfactory answers. Again I am not so confident about help as 2 of my last 3 questions are unanswered. Well Still, ma question is, Is there any way we can send friend request to any facebook user from one iOS application? Of course we have user id of that user.

As I have googled much and went through many links including

  1. how send friend request to a person in Facebook through iPhone app?
  2. Can a facebook friend request be sent from my own app?
  3. https://developers.facebook.com/docs/reference/dialogs/requests/
    etc..

And finally I found it:

http://www.facebook.com/dialog/friends?id=100002487216939&app_id=123050457758183&redirect_uri=http://www.example.com/response/

This dialog do the same what I want. So is there any equivalent for this in graph. Or something in iOS sdk, FBDialogueDelegate. Any thing that can help me out.

Upvotes: 5

Views: 7485

Answers (1)

Paul de Lange
Paul de Lange

Reputation: 10633

For user-to-user requests, you can do this (using ARC):

 NSDictionary* params = [NSDictionary dictionaryWithObjectsAndKeys: message, @"message", title, @"title", nil];
[[self facebook] dialog: @"apprequests"
                          andParams: [params mutableCopy]
                        andDelegate: delegate];

For app-to-user requests, you can do this:

NSDictionary* params = [NSDictionary dictionaryWithObjectsAndKeys: message, @"message", nil];
[[self facebook] requestWithGraphPath: @"[FRIEND ID]/apprequests"
                            andParams: [params mutableCopy]
                        andHttpMethod: @"POST"
                          andDelegate: delegate];

Make sure you have the right access tokens and the correct Facebook configuration (canvas page setup etc.) for each.

Upvotes: 1

Related Questions