【发布时间】:2023-03-17 00:44:01
【问题描述】:
我正在尝试使用带有 historyId 的 Users:History API 在 gmail 帐户中完成更改的历史记录。但不知何故,它会在完成几秒或几分钟的更改后返回数据。
代码
function listHistory($service, $userId, $startHistoryId) {
$opt_param = array('startHistoryId' => $startHistoryId);
$pageToken = NULL;
$histories = array();
do {
try {
if ($pageToken) {
$opt_param['pageToken'] = $pageToken;
}
$historyResponse = $service->users_history->listUsersHistory($userId, $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);
return $histories;
}
参考:https://developers.google.com/gmail/api/v1/reference/users/history/list
【问题讨论】: