Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook iOS SDK - Sending a facebook user an app request

Im trying to send an app request through facebook using the facebook iOS SDK, im using the following code:

NSString *message = [[NSString alloc] initWithFormat:@"blah blah blah"];
NSString *data = [[NSString alloc] initWithFormat:@"blah blah blah"];

NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:message, @"message", data, @"data", nil];
[_facebook requestWithGraphPath:[NSString stringWithFormat:@"%@/apprequests",userID] andParams:params andHttpMethod:@"POST" andDelegate:self];

[message release];
[data release];

This gives me the following error:

Error: Error Domain=facebookErrDomain Code=10000 "The operation couldn’t be completed. (facebookErrDomain error 10000.)" UserInfo=0x788c5b0 {error=<CFBasicHash 0x788c080 [0x1bf53e0]>{type = mutable dict, count = 2,
entries =>
    2 : <CFString 0x788b560 [0x1bf53e0]>{contents = "type"} = <CFString 0x788c3f0 [0x1bf53e0]>{contents = "OAuthException"}
    3 : <CFString 0x788c560 [0x1bf53e0]>{contents = "message"} = <CFString 0x788c480 [0x1bf53e0]>{contents = "(#200) Invalid Request: There was a problem with the parameters of the request. Body of an error/warning message. Title is: Invalid Request"}
}

So has anyone been successful with this, or do you know of a way to send a request to a facebook user using the facebook iOS SDK?

Thanks

like image 645
user609906 Avatar asked Dec 28 '22 18:12

user609906


1 Answers

You can easily send the app request very easily by Using Facebook SDK

For Making App Request Please Make sure Following steps

1)Make sure you have added the latest Facebook SDK in Your Application Folder

if not,you may download from this link.

Now you just need to Add FBConnect Folder in your Project Folder.

2)Then Make sure you have Registered your iphone App as "App on Facebook" Type Select how your app integrates with Facebook under Basic App Settings.

if not,you can do that here.

NSString *friendId=@"FacebookId Of Your Friends";

NSLog(@"%@",friendId);

NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:@"Hi please add me as a friend.",  @"message",
                                   friendId, @"to",
                                   nil];
 [appDelegate.facebook dialog:@"apprequests" andParams:params  andDelegate:self];

Please Don't Forget To Adopt the FBdialogDelegate protocol first in your ViewController Class.

like image 194
Kamar Shad Avatar answered Jan 30 '23 06:01

Kamar Shad