I'm using the GMail API to retrieve my labels: https://developers.google.com/gmail/api/v1/reference/users/labels/list
My code is as follows:
$userId = 'me';
$labels = array();
try {
$labelsResponse = $service->users_labels->listUsersLabels($userId);
if ($labelsResponse->getLabels()) {
$labels = array_merge($labels, $labelsResponse->getLabels());
}
foreach ($labels as $label) {
echo "<pre>";
print_r($label);
echo "</pre>";
}
} catch (Excetion $e) {
print 'An error occurred: ' . $e->getMessage();
}
This all generally seems to work however it never returns the total number of messages within the label:
Google_Service_Gmail_Label Object
(
[colorType:protected] => Google_Service_Gmail_LabelColor
[colorDataType:protected] =>
[id] => INBOX
[labelListVisibility] => labelShow
[messageListVisibility] => hide
[messagesTotal] =>
[messagesUnread] =>
[name] => INBOX
[threadsTotal] =>
[threadsUnread] =>
[type] => system
[internal_gapi_mappings:protected] => Array
(
)
[modelData:protected] => Array
(
)
[processed:protected] => Array
(
)
)
Does anyone know why this would be?