Recupere la ciudad natal, la ubicación y el cumpleaños de los amigos de Facebook usando Facebook SDK 3.0 para iOS

I am trying to get my friends hometown & location using FB SDK for iOS. But I can not retrieve friends location & hometown. Here is my code

    - (IBAction)btnFBLoginTapped:(id)sender {

    NSArray *permissions = [[NSArray alloc]initWithObjects:@"email",@"user_birthday",@"user_hometown",@"user_location",@"friends_birthday",@"friends_location",@"friends_hometown", nil];

    [FBSession openActiveSessionWithPermissions:permissions allowLoginUI:YES
                              completionHandler:^(FBSession *session,
                                                  FBSessionState status,
                                                  NSError *error) {
                                  // session might now be open.
                                  if (session.isOpen) {
                                      FBRequest *me = [FBRequest requestForMe];
                                      [me startWithCompletionHandler: ^(FBRequestConnection *connection, 
                                                                        NSDictionary<FBGraphUser> *my,
                                                                        NSError *error) {
                                          NSLog(@"My dcitionary:- %@",my);
                                          NSLog(@"Sessionkey:- %@",session.accessToken);
                                          // Friend request

                                          FBRequest *friendRequest = [FBRequest requestForMyFriends];

                                          [friendRequest startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
                                              NSDictionary *resultDictionary = (NSDictionary *)result;

                                              NSArray *data = [resultDictionary objectForKey:@"data"];

                                              NSLog(@"Data:- %@",data);

                                              for (NSDictionary *dic in data) {
                                                  NSLog(@"ID:- %@",[dic objectForKey:@"id"]);
                                              }
                                          }];
                                      }];
                                  }
                              }];
}

Also I need to retrieve friends birthday. But I can not retrieve birthday also.

¿Alguien puede ayudar con esto?

preguntado el 28 de agosto de 12 a las 11:08

2 Respuestas

data es una serie de FBGraphObject<FBGraphUser>

[friendRequest startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
    NSArray *data = [result objectForKey:@"data"];

    for (FBGraphObject<FBGraphUser> * user in data) {
        NSLog(@"%@", [user first_name]);
    }
...

Respondido 08 ago 13, 17:08

Check your logic at this point

....
[friendRequest startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
     NSDictionary *resultDictionary = (NSDictionary *)result;

Your result should be an NSArray, not an NSDictionary.

One other thing to double check the results is to put a similar query in the Graph API explorer: https://developers.facebook.com/tools/explorer

You would put me/friends in the Graph API explorer Hint: select the same application you've set up in the Graph API explorer's Application dropdown.

Respondido el 27 de Septiembre de 12 a las 01:09

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.