douchunxian9740 2017-04-07 04:34
浏览 150
已采纳

Gmail API将所有Gmail收件箱邮件限制为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.
  • 写回答

1条回答 默认 最新

  • dongteng2534 2017-04-07 12:56
    关注

    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.

    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.

    You can read the nextPageToken mentioned here in Gmail Request body

    enter image description here

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料