Search code examples
iosfacebookios7facebook-sharer

How to post text on friends wall using latest facebook sdk in IOS


How to post a link or text on friends wall using Xcode 5? Some methods are depreciated in facebook SDK. Am using following code to post on friend's wall.

NSMutableDictionary *parmaDic = [NSMutableDictionary dictionaryWithCapacity:5];
[parmaDic setObject:link forKey:@"link"];            // if you want send picture
[parmaDic setObject:@"NAME" forKey:@"name"];         // if you want to display name
[parmaDic setObject:message forKey:@"description"];  // if you want to display  description
[parmaDic setObject:@"FRIEND_FACEBOOK_ID" forKey:@"to"];
[parmaDic setObject:@"LOGO_URL" forKey:@"picture"];  // if you want to send App logo

[FBWebDialogs presentFeedDialogModallyWithSession:nil parameters:parmaDic handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error)  {
    if (error) {

 }

Solution

  • You can post on friends wall by using FBWebDialogs class of Facebook SDK. For that you need friends facebook id in parameters in dictionary as below

        NSMutableDictionary *parmaDic = [NSMutableDictionary dictionaryWithCapacity:5];
        [parmaDic setObject:link forKey:@"link"];            // if you want send picture
        [parmaDic setObject:@"NAME" forKey:@"name"];         // if you want to display name
        [parmaDic setObject:message forKey:@"description"];  // if you want to display  description
        [parmaDic setObject:@"FRIEND_FACEBOOK_ID" forKey:@"to"];
        [parmaDic setObject:@"LOGO_URL" forKey:@"picture"];  // if you want to send App logo
    
        [FBWebDialogs presentFeedDialogModallyWithSession:nil parameters:parmaDic handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error)  {
            if (error) {
    
               // Case A: Error launching the dialog or sending request.
               // NSLog(@"Error sending request.");
    
            } else {
    
                    if (result == FBWebDialogResultDialogNotCompleted) {
    
                        // Case B: User clicked the "x" icon
                        //    NSLog(@"User canceled request.");
    
                    } else {    
    
                            //   NSLog(@"Successfully Invited.");
    
                      }
                   }
             }];