【发布时间】:2020-01-26 01:30:18
【问题描述】:
我正在根据最后一个 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 中,它也包含已删除的消息。
我正在寻找可以获取所有有效/现有消息的解决方案。
【问题讨论】: