powered by Jive Software

Interface with GTalk server using SMACK APIs - Need Urgent Help -

Hi,

I am trying to create a simple program which would connect to google talk and get the buddy list from that server.

I am trying to run this program from my company’'s network.

***CODE ***********************************************************

public class GTalkTest {

public static void main(String[] args) {

try {

System.out.println(“About to open the connection”);

ConnectionConfiguration config =

new ConnectionConfiguration(“talk.google.com”,5223);

XMPPConnection connection =

new XMPPConnection(config);

System.out.println("Connection opened - "+connection);

            connection.login("shashishrimali@gmail.com", "XXXXX");

System.out.println("logged in ");

Roster roster = connection.getRoster();

if (roster==null)

{

System.out.println(“NULL”);

}

Iterator iter = roster.getEntries().iterator();

if (iter==null)

{

System.out.println(“NULL”);

}

while (iter.hasNext()) {

RosterEntry entry = (RosterEntry) iter.next();

System.out.println(entry.getName() + " (" + entry.getUser() + “)”);

}

} catch(Exception e)

{

System.out.println(e.toString());

}

}

}


OUTPUT::

About to open the connection

Connection opened - org.jivesoftware.smack.XMPPConnection@1e4457d

java.lang.IllegalStateException: Not connected to server.

Hope this code can help you:

import org.jivesoftware.smack.Chat;

import org.jivesoftware.smack.GoogleTalkConnection;

import org.jivesoftware.smack.XMPPException;

public class Codelet {

public Codelet() {

super();

}

public static void main(final String[] args) throws XMPPException {

Codelet me = new Codelet();

me.execute();

}

protected void execute() throws XMPPException {

GoogleTalkConnection con = new GoogleTalkConnection();

con.login("[MY ID]", “[PASSWORD]”);

Chat chat = con.createChat("[MY FRIEND ID]@gmail.com");

chat.sendMessage(“ASCII”);

chat.sendMessage("???");

chat.sendMessage("??");

chat.sendMessage("???");

}

}