Google Contacts API 3.0版是否检索objective C(iOS)示例请求格式的所有联系人?
在我的应用程序中,用户通过google+凭据登录,我已经为其实现了用于身份验证/授权的google+框架。成功登录后,我必须获得登录用户的联系人列表 我使用的是谷歌联系人API 3.0版url GPP登录身份验证请求后Google Contacts API 3.0版是否检索objective C(iOS)示例请求格式的所有联系人?,ios,objective-c,google-plus,google-oauth,google-contacts-api,Ios,Objective C,Google Plus,Google Oauth,Google Contacts Api,在我的应用程序中,用户通过google+凭据登录,我已经为其实现了用于身份验证/授权的google+框架。成功登录后,我必须获得登录用户的联系人列表 我使用的是谷歌联系人API 3.0版url GPP登录身份验证请求后 - (void)finishedWithAuth:(GTMOAuth2Authentication *)auth error:(NSError *)error { if (error) { NSLog(@"%@",[N
- (void)finishedWithAuth:(GTMOAuth2Authentication *)auth
error:(NSError *)error {
if (error) {
NSLog(@"%@",[NSString stringWithFormat:@"Status: Authentication error: %@", error]);
return;
}
auth.clientID =@"XXXX.apps.googleusercontent.com";
auth.clientSecret =@"xxxxxxxx-z7tmOqQCShgH3ax";
NSString *urlStr = @"https://www.google.com/m8/feeds/contacts/default/full";
NSURL *url = [NSURL URLWithString:urlStr];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setHTTPMethod:@"GET"];
[request setValue:@"3.0" forHTTPHeaderField:@"GData-Version"];
auth.scope= @"https://www.googleapis.com/auth/contacts.readonly";
[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) {
// API fetch succeeded :Here I am getti
output = [[NSString alloc] initWithData:data
encoding:NSUTF8StringEncoding];
NSLog(@"%@", output);
} else {
// fetch failed
output = [error description];
}
}
}];
}
在成功的响应中,我编写了如下代码
但产出并不理想。
输出字符串是一个巨大的垃圾值,在它的末尾显示
401。这是一个错误。有一个错误
您的请求中有错误。我们就这些
知道
请任何人帮忙解决这个问题。401表示您没有正确授权。我不使用该api,但您的凭据可能不正确 您可能还看到https的证书问题?您应该设置此回拨,看看它是否提供了更多信息
凭据没有问题,如果我使用与GData相同的凭据,我就能够获得联系人。我已经实现了您提供的链接中提到的NSURLConnection SSL证书委托方法。我发现证书也没有问题,Hello@CKT你有进一步的工作吗?我也陷入了这种境地。请帮帮我。非常感谢。