如何发送gtalk与smack java库联系的邀请?
答案 0 :(得分:4)
//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
答案 1 :(得分:0)
使用下面的代码,您可以与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");
答案 2 :(得分:0)
您可以通过以下方式实现Gtalk联系:
GoogleTalkConnection con = new GoogleTalkConnection();
con.login(”joesmith”, “password”);
con.createChat(”maryjane@gmail.com”).sendMessage(”Howdy!”);
con.close();