如何在所有gmail文件夹中统计在特定日期收到的电子邮件。设法使电子邮件收件箱计数工作正常,但现在需要弄清楚如何使用PHP和oauth获得前一天收到的数字。有人能帮忙吗?
messages#list方法允许您传递一个q
参数,该参数接受来自Gmail搜索字段的相同查询格式。
因此可以做到这一点:
// $gmail is an instance of Google_Service_Gmail
$messages = $gmail->users_messages->listUsersMessages('me', array(
'q' => "after:2014/10/20 before:2014/10/21"
));
// $count is the number of messages from 2014/10/20
$count = $messages->getResultSizeEstimate();
注意,如果你打开了"对话视图",结果将与你在Gmail中看到的不同。