Gmail Oauth API get message count
The new Gmail API now allows you to count the number of messages and unread emails inside a label. But I can't get it to work and have tried a lot of things. It's properly connected to Oauth, but can't get the account to work. I am using below code: -
$labelall = $service->users_labels->listUsersLabels('me');
$labels = $labelall->getLabels();
foreach ($labels as $label) {
print 'Label with ID: ' . $label->getId() . ',
Number of Messages:'.$label->getMessagesTotal().'<br/>';}
Can anyone please help? It renders the labels correctly, but the number of posts returns null.
Thank!
+3
source to share