How to send message to selected facebook friend in

2019-07-25 12:05发布

问题:

In my application I'm getting friend list of logged in user and by selecting any one I can get his details like name, photo, id etc.

But my question is that I need to send message to selected user by using his details like id with Facebook SDK 3.1.

回答1:

if you want to post to users wall try this one :

    NSMutableDictionary *postTest = [[NSMutableDictionary alloc]init];
    [postTest setObject:[NSString stringWithFormat@"Your message"] forKey:@"message"];
    [postTest setObject:@"" forKey:@"picture"];
    [postTest setObject:@"" forKey:@"name"];
    [postTest setObject:@"APPID" forKey:@"app_id"];
    NSString *userFBID =[NSString stringWithFormat:@"%@",[allInfoDict objectForKey:@"Friends facebook ID "]];

    [FBRequestConnection startWithGraphPath:[NSString stringWithFormat:@"%@/feed?access_token=%@",userFBID,[appDelegate.mysession accessToken]]
                                 parameters:postTest
                                 HTTPMethod:@"POST"
                          completionHandler:^(FBRequestConnection *connection,
                                              NSDictionary * result,
                                              NSError *error) {
                              if (error) {
                                  [self hideHUD];
                                  NSLog(@"Error: %@", [error localizedDescription]);

                              } else {
                                  // Success

                              }
                          }];

    [postTest release];