简体   繁体   中英

Google+ does not return user's friend's email address

I am trying to access friendslist of user's google+ account.

I have used this code for this purpose...

-(void)getGooglePlusAccounts:(NSString *)notificationNameStr
{
    GTLServicePlus* plusService = [[GTLServicePlus alloc] init];
    plusService.retryEnabled = YES;

    [plusService setAuthorizer:[[GPPSignIn sharedInstance] authentication]];

    GTLQueryPlus *query =
    [GTLQueryPlus queryForPeopleListWithUserId:@"me"
                                    collection:kGTLPlusCollectionVisible];
    [plusService executeQuery:query
            completionHandler:^(GTLServiceTicket *ticket,
                                GTLPlusPeopleFeed *peopleFeed,
                                NSError *error) {
                if (error) {
                    NSLog(@"Error: %@", error);
                } else {
                    // Get an array of people from GTLPlusPeopleFeed
                    NSArray* peopleList = peopleFeed.items;
                    NSLog(@"peopleList: %@", peopleList);

            }];
}

This will gives me UserID, Image, Name but not email.

How can i find the email for the Friend.

You can't get the email address for a friend if that person has not set there email address public. So the reason you are not getting an email address returned for your friend is because they have not set the email address public.

To fix this tell your friend to set his email address public. :)

Following quote from the documentation Google+ api - People

emails[] list A list of email addresses that this person has, including their Google account email address, and the public verified email addresses on their Google+ profile. The plus.profile.emails.read scope is needed to retrieve these email addresses, or the email scope can be used to retrieve just the Google account email address.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM