0

I am trying to post texts and image using Facebook Feed Dialog , I am able to post to my own wall but not able to tag friends . I am able to choose a friend from FBFriendPickerViewController , but when i click done but i am getting return error 5 . In one of stackoverflow questions (ios-Facebook SDK 3.0 Error 5 When Posting Status Update) there were a few ways where one can get this error , I have corrected all the possible ways which was mentioned in that question .

and is the feed dialog correct [FBRequestConnection startWithGraphPath:@"%@/feed" parameters:params

This is my code ,

- (IBAction)pickFriendsList:(UIButton *)sender
{
    FBFriendPickerViewController *friendPickerController = [[FBFriendPickerViewController alloc] init];
    friendPickerController.title = @"Pick Friends";
    [friendPickerController loadData];

    [friendPickerController presentModallyFromViewController:self animated:YES handler:
     ^(FBViewController *sender, BOOL donePressed) {

         if (!donePressed) {
             return;
         }

         NSString* fid;
         NSString* fbUserName;

         for (id<FBGraphUser> user in friendPickerController.selection)
         {
             NSLog(@"\nuser=%@\n", user);
             fid = user.id;

             fbUserName = user.name;

             NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:@"aaaaaa", @"message", @"http://webecoist.momtastic.com/wp-content/uploads/2009/01/nature-wonders.jpg", @"picture", @"My Susfsdfsdfs sdf sfsdfp", @"name", nil];

             NSLog(@"\nparams=%@\n", params);


             [FBRequestConnection startWithGraphPath:@"%@/feed" parameters:params HTTPMethod:@"POST"
                                   completionHandler:^(FBRequestConnection *connection, id result, NSError *error)


              {
                  //Tell the user that it worked.
                  UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Shared"
                                                                      message:[NSString stringWithFormat:@"Invited %@! error=%@", fbUserName, error]
                                                                     delegate:nil
                                                            cancelButtonTitle:@"OK"
                                                            otherButtonTitles:nil];

                  [alertView show];
                  NSLog(@"%@ alertview description",alertView.message);

              }
              ];

         }

     }];

}

enter image description hereenter image description hereenter image description hereenter image description here

Error :

> Error Domain=com.facebook.sdk Code=5 "The operation couldn’t be
> completed. (com.facebook.sdk error 5.)" UserInfo=0xa157bf0
> {com.facebook.sdk:HTTPStatusCode=500,
> com.facebook.sdk:ParsedJSONResponseKey={
>     body =     {
>         error =         {
>             code = 1;
>             message = "An unknown error has occurred.";
>             type = OAuthException;
>         };
>     };
>     code = 500; }, com.facebook.sdk:ErrorSessionKey=<FBSession: 0x9491490, state: FBSessionStateOpen, loginHandler: 0x946f8d0, appID:
> 511223775602729, urlSchemeSuffix: ,
> tokenCachingStrategy:<FBSessionTokenCachingStrategy: 0x948f2b0>,
> expirationDate: 2013-06-15 05:04:17 +0000, refreshDate: 2013-04-16
> 10:36:11 +0000, attemptedRefreshDate: 0001-12-30 00:00:00 +0000,
> permissions:( )>}
raptor
  • 291
  • 1
  • 9
  • 17

2 Answers2

1

Note: you are missing FB User ID in your code

Change your code as below:

[FBRequestConnection
             startWithGraphPath:[NSString stringWithFormat:@"%@/feed", fid]
             parameters:params
             HTTPMethod:@"POST"
             completionHandler:^(FBRequestConnection *connection,
                                 id result,
                                 NSError *)

Regards,

Ravi Trivedi
  • 2,340
  • 2
  • 14
  • 20
  • Don't worry, we will figure it out. Ok, now your error says it has some problem with FBsession. Can you please post your full error in code block, thanks ! – Ravi Trivedi Apr 16 '13 at 09:15
  • Very nice ! Will check it out once I get some free time. – Ravi Trivedi Apr 16 '13 at 22:15
  • i have a question regarding the above problem ..cant i post a data to multiple friends at same time using FBWebDialog instead of separate FBWebDialog for each friend ..http://stackoverflow.com/questions/16834007/how-to-share-multiple-post-on-friends-wall-in-objective-c – raptor May 30 '13 at 17:08
0

You can use checkins or, Open Graph actions to tag friends in facebook, for checkins the app will require permission for that, but will work with basic app settings. But for Open Graph there are multiple settings you will have to do.. You can have a look into here

iphonic
  • 12,615
  • 7
  • 60
  • 107
  • `feed` is normally used for the user feed. You need to pass parameter on `%@` to tell facebook on which user's wall you are posting, here you need to give your friend's userid, or if you want to post on your wall it would be `me/feed`. So it should look like `/feed`. – iphonic Apr 15 '13 at 06:57