如何将邀请函发送到与Smack Java库的GTALK联系?
-
30-09-2019 - |
题
如何将邀请函发送到与Smack Java库的GTALK联系?
解决方案
//Setting up connection
ConnectionConfiguration config = new ConnectionConfiguration("talk.google.com", 5222, "gmail.com");
connection = new XMPPConnection(config);
connection.connect();
//login
connection.login(userName, password);
//get your roster
Roster roster = connection.getRoster();
//add a new roster entry aka SEND INVITATION
roster.createEntry(address, name, groups);
有关更多详细信息,请查看此页面:http://www.igniterealtime.org/builds/smack/docs/3.1.0/javadoc/org/jivesoftware/smack/roster.html
其他提示
使用下面的代码,您可以与GTALK构建联系人。
ConnectionConfiguration conf = new ConnectionConfiguration(
"talk.google.com",
5222,
"gmail.com");
conf.setSASLAuthenticationEnabled(false);
XMPPConnection con = new XMPPConnection(conf);
con.connect();
/*
* username : username@gmail.com
* password :
*/
con.login("username", "password");
您可以按以下方式实现GTALK联系:
GoogleTalkConnection con = new GoogleTalkConnection();
con.login(”joesmith”, “password”);
con.createChat(”maryjane@gmail.com”).sendMessage(”Howdy!”);
con.close();
不隶属于 StackOverflow