从Parse Facebook API获取位置

时间:2014-02-17 13:16:30

标签: ios iphone facebook ipad parse-platform

我正在开发iPhone应用程序,我正在使用Parse 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 = "sunilvliya@gmail.com";
    "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;
}

我想从上面的数据中获取位置名称,我该怎么做?

请提前帮助和致谢。

1 个答案:

答案 0 :(得分: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"];

     }];