I am working on an iPhone app in which I am giving user option to login with his/her google account. Now, I want that user's google email id through JSON or XML. I have searched a lot, but did not satisfactory result. Thanx in advance.
did you check the oauth autorization with google api at their developers site? https://developers.google.com/accounts/docs/OAuth2
i think you can find something from this link..... hope this link help you..... http://code.google.com/p/gdata-objectivec-client/wiki/GDataObjCIntroduction and also https://code.google.com/p/gdata-objectivec-client/ :)
write bellow code when you want to get contact....
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 method is GmailAPI delegate method...
- (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;
}
after that you can get contact with bellow code...
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];
}
hope this help you.... :)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.