2014-12-30 31 views
0

我想获取用户邮箱的当前状态(HistoryId),以便在同一状态之后的任何新邮件都被同步。如何从Gmail API获取UserProfile?

按照谷歌API this试过在他们返回以下字段

{ 
    "emailAddress": string, 
    "messagesTotal": integer, 
    "threadsTotal": integer, 
    "historyId": unsigned long 
} 

由于我的代码是在java中我尝试了他们,但只返回用户id

代码:

service.users().getProfile(user); 

服务是Gmail验证的服务对象,用户是userId

API参考号:=>

任何帮助赞赏!

回答

0

请尝试以下操作上述规定,以获取所有信息:

一旦导入此类引用:

com.google.api.services.gmail.model.Profile 

然后,当你实例化对象它有下列方法。 我会认为这是东西线(不完整的代码 - 唯一指示):

Profile.getEmailAddress(); 

Profile.getMessagesTotal(); 
Profile.getThreadsTotal(); 
Profile.getHistoryId(); 

Gmail Profile class

+0

所有授权和认证完成。我面临getProfile的拆分行为,在GoogleAPI上尝试它,它工作正常,并使用java代码它只返回userId – Ninad

相关问题