2016-10-04 63 views
2

以下是我的代碼,使用GIDSignIn登錄名從Google帳戶獲取人員/聯繫人。iOS:無法獲取所有Google人員api收藏列表

代碼:

- (void)setAuthorizerForSignIn:(GIDSignIn *)signIns user:(GIDGoogleUser *)user { 
    GTMOAuth2Authentication *auth = [[GTMOAuth2Authentication alloc] init]; 
    [auth setClientID:signIns.clientID]; 
    [auth setUserEmail:user.profile.email]; 
    [auth setUserID:user.userID]; 
    [auth setAccessToken:user.authentication.accessToken]; 
    [auth setRefreshToken:user.authentication.refreshToken]; 
    [auth setExpirationDate: user.authentication.accessTokenExpirationDate]; 
    appDelegate.authGooglePlus = auth; 
    NSString *urlStr = @"https://people.googleapis.com/v1/people/me/connections?pageSize=200"; 
    NSURL *url = [NSURL URLWithString:urlStr]; 
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; 
    [request setHTTPMethod:@"GET"]; 
    auth.scope= @"https://www.googleapis.com/auth/contacts"; 
    [auth authorizeRequest:request 
      completionHandler:^(NSError *error) { 
       NSString *output = nil; 
       if (error) { 
        output = [error description]; 
       } else { 
        NSURLResponse *response = nil; 
        NSData *data = [NSURLConnection sendSynchronousRequest:request 
                 returningResponse:&response 
                    error:&error]; 
        if (data) { 
         output = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; 
         NSMutableArray *array = [[output JSONValue] objectForKey:@"connections"]; 
         } 
        } else { 
         // fetch failed 
         output = [error description]; 
        } 
       } 
      }]; 
} 

以下是我的代碼來獲取人/聯繫人列表,但我能夠得到的只有7條並不是所有的記錄,不知道如何做到這一點?

回答

0

Google People API只返回聯繫人組中的聯繫人。問題很可能是其他記錄是「其他聯繫人」,它們不在任何聯繫人組中,因此不會被返回。

目前無法從Google People API獲取其他聯繫人。