2014/11/21

[Objective-C][iOS][Google]Google plus SDKで個人情報を取得

Google plus SDKを使って認証する方法を書きましたが、それをもとに、自分の情報を取得するには、どうすればいいのだろうか?

- (void)finishedWithAuth: (GTMOAuth2Authentication *)auth error: (NSError *) error {
    //errorがある場合、ない場合は、nilを返す
    if(error){
      return
    }

    GTLServicePlus* plusService = [[GTLServicePlus alloc] init];
    plusService.retryEnabled = YES;
    [plusService setAuthorizer:[GPPSignIn sharedInstance].authentication];

    GTLQueryPlus *query = [GTLQueryPlus queryForPeopleGetWithUserId:@"me"];
    [plusService executeQuery:query
        completionHandler:^(GTLServiceTicket *ticket,
                            GTLPlusPerson *person,
                            NSError *error) {
            if (error) {
                GTMLoggerError(@"Error: %@", error);
            } else {
                //person.displayName
                //person.identifer
             }
    }];
}

0 コメント:

コメントを投稿