如何让Gmail未读数 [英] How to get Gmail unread count

查看:167
本文介绍了如何让Gmail未读数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下代码在Gmail中获取未读电子邮件数量。但是,它返回错误:

 无法连接:登录失败太多


(IMAP和POP已启用我测试的Gmail帐户。)






注意:正在工作(至少对于大多数请求)。但是,这个过程太漫长了 - 大概需要2-3分钟才能回来。有没有办法加快速度?




谢谢!

 <?php 

$ mbox = imap_open({imap.gmail.com:993/imap/ssl/novalidate-cert/ norsh} Inbox,
username,password,OP_READONLY)
或die(无法连接:。imap_last_error());
$ check = imap_mailboxmsginfo($ mbox);
if($ check){
print $ check-> Unread; //。 /。 $入住> Nmsgs;
} else {
printFailed;
}

?>


解决方案

您也可以使用 Gmail收件箱Feed 以获取未读的计数。
只需将已通过身份验证的GET请求发送至 https://mail.google.com/mail/ feed / atom 并检查 fullcount 元素的值。


I am using the following code to get the Unread emails count in Gmail. However, it is returning the error:

can't connect: Too many login failures

Is there anything I am missing here?

(IMAP and POP are enabled in the Gmail account I am testing.)


NOTE: It looks like it is working (at least for most of the requests). However, it is taking way too long - maybe 2 - 3 minutes to come back with a number. Is there a way to speed it up?


Thanks!

<?php

$mbox = imap_open ("{imap.gmail.com:993/imap/ssl/novalidate-cert/norsh}Inbox", 
"username", "password", OP_READONLY) 
or die("can't connect: " . imap_last_error()); 
$check = imap_mailboxmsginfo($mbox); 
if ($check) { 
print $check->Unread; //. "/" . $check->Nmsgs; 
} else { 
print "Failed"; 
}

?>

解决方案

You can also use the Gmail Inbox Feed to get the unread count. Just send an authenticated GET request to https://mail.google.com/mail/feed/atom and check the value of the fullcount element.

这篇关于如何让Gmail未读数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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