开发者

get gmail user available status

I have email list for my gmail id...it got using XMPP...how can i get those 开发者_运维百科user status availability in java...


Here is an example using Smack

SASLAuthentication.supportSASLMechanism("PLAIN");
ConnectionConfiguration config = new ConnectionConfiguration(
      "talk.google.com", 5222, "gmail.com");
XMPPConnection conn = new XMPPConnection(config);
conn.connect();
conn.login("yourid@gmail.com", "password");
Roster roster = conn.getRoster();
Collection<RosterEntry> set = roster.getEntries();
for (RosterEntry re: set) {
   System.out.println(">> " + re.getUser());            
   Presence pres = roster.getPresence(re.getUser());
   //This is the status. 
   System.out.println("\t> " + pres.getMode());
}

Use Prescence.getStatus() to get the message string

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜