3
3

More than 5 years have passed since last update.

Facebook SDKで日本語の名前を取得する

Posted at

        [FBRequestConnection startWithGraphPath:@"me"
                                     parameters:@{
                                                  @"fields":@"id,birthday,name”,  // 取得したいFieldを選択する
                                                  @"locale":@“ja_JP”              // 言語選択
                                                  }
                                     HTTPMethod:@“GET” // POSTだとエラーになる
                              completionHandler:
         ^(
           FBRequestConnection *connection,
           id result,
           NSError *error
         ){
             if (error) {
                 NSLog(@"Error: %@", error);
             } else {
                 // 取得が成功したら、DictinaryのKEYにFieldの値を指定して取得する
                 NSDictionary* resultDict = (NSDictionary*)result;
                 NSString *name = resultDict[@"name”];



                 // 他で使えるように、プロパティに入れる
                 self.name = name;
                 NSLog(@"Result: %@", self.name);
             }
         }];
3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3