【问题标题】:How to get UserProfile from Gmail API?如何从 Gmail API 获取 UserProfile?
【发布时间】:2015-02-26 11:45:36
【问题描述】:

我想获取用户邮箱 (HistoryId) 的当前状态,以便同步该状态之后的任何新邮件。

根据 Google API this 对其进行了尝试,它返回以下字段

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

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

代码:

service.users().getProfile(user);

service 是 Gmail 认证的服务对象,user 是 userId

API 参考:=>

任何帮助表示赞赏!

【问题讨论】:

    标签: java email gmail gmail-api


    【解决方案1】:

    请尝试以下方法来检索上述指定的所有信息:

    导入此类引用后:

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

    然后它在实例化对象时公开以下方法。 我认为这是(不完整的代码 - 仅指示):

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

    Gmail Profile class

    【讨论】:

    • 所有授权和身份验证都已完成。我正面临 getProfile 的拆分行为,在 GoogleAPI 上尝试一下,它工作正常,并且使用 java 代码它只返回 userId
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-10-27
    • 2014-12-07
    • 2018-12-23
    • 1970-01-01
    • 2015-11-02
    • 2017-01-10
    • 2019-07-12
    相关资源
    最近更新 更多