我正在开发一款iPhone应用程序,我可以让用户选择使用他/她的谷歌帐户登录。现在,我希望该用户的谷歌电子邮件ID通过JSON或XML。我搜索了很多,但结果不尽如人意。 提前完成。
答案 0 :(得分:0)
您是否在开发者网站上使用google api检查了oauth授权? https://developers.google.com/accounts/docs/OAuth2
答案 1 :(得分:0)
我想你可以从这个链接找到一些东西...... 希望这个链接可以帮助你...... http://code.google.com/p/gdata-objectivec-client/wiki/GDataObjCIntroduction 和 还https://code.google.com/p/gdata-objectivec-client/ :)
当您想要联系时写下以下代码....
GDataServiceGoogleContact *service = [self contactService];
GDataServiceTicket *ticket;
BOOL shouldShowDeleted = TRUE;
const int kBuncha = 2000;
NSURL *feedURL = [GDataServiceGoogleContact contactFeedURLForUserID:kGDataServiceDefaultUser];
GDataQueryContact *query = [GDataQueryContact contactQueryWithFeedURL:feedURL];
[query setShouldShowDeleted:shouldShowDeleted];
[query setMaxResults:kBuncha];
ticket = [service fetchFeedWithQuery:query
delegate:self
didFinishSelector:@selector(contactsFetchTicket:finishedWithFeed:error:)];
[self setContactFetchTicket:ticket];
bellow方法是GmailAPI委托方法......
- (GDataServiceGoogleContact *)contactService
{
static GDataServiceGoogleContact* service = nil;
if (!service) {
service = [[GDataServiceGoogleContact alloc] init];
[service setShouldCacheResponseData:YES];
[service setServiceShouldFollowNextLinks:YES];
}
[service setUserCredentialsWithUsername:txtEmail.text
password:txtPass.text];
return service;
}
之后你可以联系bellow代码...
for (int i = 0; i < [contacts count]; i++) {
GDataEntryContact *contact = [contacts objectAtIndex:i];
// NSLog(@">>>>>>>>>>>>>>>> elementname contact :%@", [[[contact name] fullName] contentStringValue]);
NSString *ContactName = [[[contact name] fullName] contentStringValue];
GDataEmail *email = [[contact emailAddresses] objectAtIndex:0];
// NSLog(@">>>>>>>>>>>>>>>> Contact's email id :%@ contact name :%@", [email address], ContactName);
NSString *ContactEmail = [email address];
}
希望这对你有所帮助....
:)