[英]Gmail API getting all Gmail Inbox messages limits to 500
I am trying to get all the inbox messages in the Gmail API, but it's limiting to 500 per request. 我正在尝试在Gmail API中获取所有收件箱邮件,但每个请求限制为500个。 I would like to get all the messages, and the current messages in the repository is 1600+ but I am only able to get 500 on one request.
我想获取所有消息,并且存储库中的当前消息为1600+,但是一次请求只能获得500。
$service = new Google_Service_Gmail($client);
$user = 'me';
$params = array(
'labelIds' => 'INBOX',
'maxResults' => 20000
);
$last_date = mysqli_fetch_array($query);
extract($last_date);
$date = date_create($latest);
$date->modify('-1 day');
$filter_date = date_format($date, 'Y/m/d');
$params['q'] = 'in:inbox after:'.$filter_date ;
$messages = $service->users_messages->listUsersMessages( $user, $params );
$list = $messages->getMessages();
//$list only has 500 messages returned to me.
Just to add clarity, this is what's happening. 只是为了增加清晰度,这就是正在发生的事情。 You performed a Users.messages: list which fetches 1600+ messages.
您执行了一个Users.messages:列表 ,该列表可提取1600多个消息。 Now I'm pretty sure Gmail fetched those 1600+ messages but it can only display 500 messages at a time.
现在,我很确定Gmail可以提取1600余封邮件,但一次只能显示500封邮件。
If you want to access the next 501-1000 messages, you need to use the nextPageToken
which comes with every successful response. 如果要访问下一条501-1000消息,则需要使用每个成功响应随附的
nextPageToken
。 That goes on for the next 1001-1500 messages and so forth. 接下来的1001-1500消息以此类推。
You can read the nextPageToken
mentioned here in Gmail Request body 您可以阅读Gmail请求正文中此处提到的
nextPageToken
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.