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

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

报告相同问题?

悬赏问题

  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化