Gmail API获取所有Gmail收件箱邮件的限制为500 [英] Gmail API getting all Gmail Inbox messages limits to 500

查看:149
本文介绍了Gmail API获取所有Gmail收件箱邮件的限制为500的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Gmail API中获取所有收件箱邮件,但每个请求限制为500个.我想获取所有消息,并且存储库中的当前消息为1600+,但一次请求只能获得500.

I am trying to get all the inbox messages in the Gmail API, but it's limiting to 500 per request. 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.

$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.

推荐答案

只是为了增加清晰度,这就是正在发生的事情.您执行了一个 Users.messages:list 来获取超过1600条讯息.现在,我很确定Gmail可以提取1600多个邮件,但一次只能显示500封邮件.

Just to add clarity, this is what's happening. You performed a Users.messages: list which fetches 1600+ messages. Now I'm pretty sure Gmail fetched those 1600+ messages but it can only display 500 messages at a time.

如果要访问下一条501-1000消息,则需要使用每个成功响应随附的nextPageToken.接下来的1001-1500消息中将继续执行此类操作.

If you want to access the next 501-1000 messages, you need to use the nextPageToken which comes with every successful response. That goes on for the next 1001-1500 messages and so forth.

您可以阅读

这篇关于Gmail API获取所有Gmail收件箱邮件的限制为500的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆