2014-02-17 142 views
0

我开发的iPhone应用程序,其中我在使用解析API获取位置

而在与Facebook做标志做标志与Facebook,我收到了大量的登录用户信息(下面给出的),我想从中获取用户的位置。

userdata ={ 
    birthday = "05/21/1987"; 
    education =  (
       { 
      school =    { 
       id = 120844281263915; 
       name = Gurukul; 
      }; 
      type = "High School"; 
      year =    { 
       id = 143018465715205; 
       name = 2000; 
      }; 
     }, 
       { 
      school =    { 
       id = 518699864812774; 
       name = VJTI; 
      }; 
      type = College; 
     } 
    ); 
    email = "[email protected]"; 
    "first_name" = Sunil; 
    gender = male; 
    hometown =  { 
     id = 108867759137051; 
     name = Jamnagar; 
    }; 
    id = 100002439055169; 
    "last_name" = Vadoliya; 
    link = "https://www.facebook.com/sunil.vya.9"; 
    locale = "en_US"; 
    location =  { 
     id = 108867759137051; 
     name = Jamnagar; 
    }; 
    name = "Sunil Valiya"; 
    timezone = "5.5"; 
    "updated_time" = "2012-07-18T13:58:11+0000"; 
    username = "sunil.vliya.9"; 
    verified = 1; 
} 

我想从上面的数据获取位置名称,我怎么能得到它?

请帮助和提前致谢。

回答

0

您需要再次向Facebook API发送请求以获取有关该位置的信息。您提供的用户数据包括位置和家乡。为了从用户的当前城市获取信息,您可以提出这样的要求。

NSString *locationId = [[theDictionaryWithUserData objectForKey:@"location"] objectForKey:@"id"]; 
    FBRequest *requesetForCity = [FBRequest requestForGraphPath:locationId]; 
    [requesetForCity startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error){ 

    NSLog(@"%@", result); 

    NSString *locationName = [result objectForKey:@"name"]; 

    }]; 
+0

仍然我没有变老家:( – Krunal