Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 880
rptwsthi Avatar asked Nov 13 '22 02:11

rptwsthi


1 Answers

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.

like image 58
Paul de Lange Avatar answered Nov 16 '22 04:11

Paul de Lange