无法在iPhone中获取Gmail通讯录

时间:2014-04-07 07:20:14

标签: iphone ios7 gmail

从最近几天开始,我陷入困境,因为我无法在我的iPhone应用程序中访问我的Gmail通讯录。我搜索了很多但没有取得任何成功。 这是我所评论的链接 I checked this link also to access gmail contacts

在上面的链接中,您可以使用此网址访问联系人 的 https://www.google.com/m8/feeds/contacts/userEmail/full 我能够使用GData框架登录,但没有找到任何东西来获取gmail联系人。 成功登录后我有一个访问令牌,我在成功登录后调用了这个方法。

- (void)doAnAuthenticatedAPIFetch {
    NSString *urlStr = @"https://www.google.com/m8/feeds/contacts/myEmailId@gmail.com/full";
    NSURL *url = [NSURL URLWithString:urlStr];
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
    [self.authToken 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) {
                          // API fetch succeeded :Here I am getti
                          output = [[NSString alloc] initWithData:data
                                                         encoding:NSUTF8StringEncoding];
                      } else {
                          // fetch failed
                          output = [error description];
                      }
                  }
              }];

}

请指导我。

1 个答案:

答案 0 :(得分:0)

使用此网址获取Gmail帐户地址簿。

http://code.google.com/p/gdata-objectivec-client/wiki/GDataObjCIntroduction

从这里接受如何使用google api的指示。

http://johntwang.com/blog/2009/06/08/how-to-use-google-apis-with-iphone-sdk/

希望这对你有用。