如何从历史列表中排除 "Deleted messages"
How to exclude "Deleted messages" from Historylist
我正在根据上次 history_id 同步用户的电子邮件,并且工作正常。
但有时它不起作用并显示消息未找到错误。
我查了一下发现,是同步从收件箱中删除或退回的邮件。
我在 $opt_pram 数组 'historyTypes'=>'messageAdded'
中又添加了一个参数,但它仍然获取所有已删除消息的消息。
我也尝试过使用 labelIds= INBOX 但它不起作用。
$opt_param = array('historyTypes'=>'messageAdded','startHistoryId' => $history_id,'maxResults'=>100);
$pageToken = NULL;
$histories = array();
do {
try {
if ($pageToken) {
$opt_param['pageToken'] = $pageToken;
}
$historyResponse = $service->users_history->listUsersHistory($user, $opt_param);
if ($historyResponse->getHistory()) {
$histories = array_merge($histories, $historyResponse->getHistory());
$pageToken = $historyResponse->getNextPageToken();
}
} catch (Exception $e) {
print 'An error occurred: ' . $e->getMessage();
}
} while ($pageToken);
在 $histories
中,它也包含已删除的消息。
我正在寻找可以获取所有 valid/existing 条消息的解决方案。
'historyTypes'=>'messageAdded'
将显示自相应 startHistoryId
创建以来添加的所有消息,即使这些消息已被荒谬地删除。
作为解决方法,我建议您对 'historyTypes'=>'messageDeleted'
进行第二次查询,然后比较各自查询响应中包含的消息 ID,并仅同步 'historyTypes'=>'messageAdded'
查询中包含的消息,但不在 'historyTypes'=>'messageDeleted'
查询中。
我正在根据上次 history_id 同步用户的电子邮件,并且工作正常。 但有时它不起作用并显示消息未找到错误。 我查了一下发现,是同步从收件箱中删除或退回的邮件。
我在 $opt_pram 数组 'historyTypes'=>'messageAdded'
中又添加了一个参数,但它仍然获取所有已删除消息的消息。
我也尝试过使用 labelIds= INBOX 但它不起作用。
$opt_param = array('historyTypes'=>'messageAdded','startHistoryId' => $history_id,'maxResults'=>100);
$pageToken = NULL;
$histories = array();
do {
try {
if ($pageToken) {
$opt_param['pageToken'] = $pageToken;
}
$historyResponse = $service->users_history->listUsersHistory($user, $opt_param);
if ($historyResponse->getHistory()) {
$histories = array_merge($histories, $historyResponse->getHistory());
$pageToken = $historyResponse->getNextPageToken();
}
} catch (Exception $e) {
print 'An error occurred: ' . $e->getMessage();
}
} while ($pageToken);
在 $histories
中,它也包含已删除的消息。
我正在寻找可以获取所有 valid/existing 条消息的解决方案。
'historyTypes'=>'messageAdded'
将显示自相应 startHistoryId
创建以来添加的所有消息,即使这些消息已被荒谬地删除。
作为解决方法,我建议您对 'historyTypes'=>'messageDeleted'
进行第二次查询,然后比较各自查询响应中包含的消息 ID,并仅同步 'historyTypes'=>'messageAdded'
查询中包含的消息,但不在 'historyTypes'=>'messageDeleted'
查询中。