I am developing an iOS app in which I have to invite to user Facebook Friends to join the app. I am using Social Framework to do so. I have successfully posted on FB wall of logged in user but there is a problem in the message which I posted. the message says that "User has shared a link via sample app. Pleas join this awesome app.". I want the message:
"User -> Friend Please join this awesome app.".
I want it like when it appears when we write on Friend FB Wall.
I have added the "to" parameter in which I am passing the friend's unique FB id. But it's not working.
Below is the code which I am using for this:
[accountStore requestAccessToAccountsWithType:facebookAccountType options:dict completion:^(BOOL granted, NSError *error)
{
if (granted)
{
__block ACAccount * facebookAccount;
NSDictionary *options = @{ ACFacebookAppIdKey: **FBAPPID**, ACFacebookPermissionsKey: permissions, @"ACFacebookAudienceKey": ACFacebookAudienceFriends };
[accountStore requestAccessToAccountsWithType:facebookAccountType options:options completion:^(BOOL granted, NSError *error)
{
if (granted)
{
NSArray *accounts = [accountStore accountsWithAccountType:facebookAccountType];
facebookAccount = [accounts lastObject];
NSURL *postURL = [NSURL URLWithString:@"https://graph.facebook.com/me/feed"];
NSMutableDictionary *postDict = [NSMutableDictionary dictionaryWithObjectsAndKeys:
**FRIENDID**, @"to",**FRIENDNAME**, @"name",@"Testing of app.", @"caption", @"please join this awesome app.", @"message", nil];
SLRequest *postToMyWall = [SLRequest requestForServiceType:SLServiceTypeFacebook requestMethod:SLRequestMethodPOST URL:postURL parameters:postDict];
[postToMyWall setAccount:facebookAccount];
[postToMyWall performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error)
{
if (error) {
}
else
{
NSLog(@"Post successful");
NSString *dataString = [[NSString alloc] initWithData:responseData encoding:NSStringEncodingConversionAllowLossy];
NSLog(@"Response Data: %@", dataString);
[self performSelectorOnMainThread:@selector(postSuccess) withObject:nil waitUntilDone:NO];
}
}];
}
else
{
NSLog(@"rfc");
}
}];
}
else
{
[self performSelectorOnMainThread:@selector(showerrorAlert:) withObject:error waitUntilDone:NO];
}
}];
Please if anyone can give a solution for this. I can use Facebook Framework also but I need to authorize the user and fetch his/her friend list using the credentials stored in iPhone Device Settings. So if you have an alternate solution then please let me know.