I'm using Gmail API to fetch email address (of the sender) for last 10 emails.
URL: https://developers.google.com/gmail/api/v1/reference/users/messages/list
But Users.messages: list
API returns message resource (which includes only email ID).
And for fetching sender email address, I have to make one Users.messages: get
API call for each message resources, that's increases load time.
How can I fetch email address of sender along with email ID in the response of Users.messages: list
API?
OR Somehow I can fetch last 10 sender email address in one API call?
My current code Example:
$params = [
'labelIds' => 'INBOX',
'maxResults' => 10
];
$emails = $service->users_messages->listUsersMessages('me', $params);
foreach ($emails->getMessages() as $email) {
$email_data = $service->users_messages->get('me', $email->id, ['format' => 'full']);
}