How to telnet into facebook chat

2

I was able to use facebook chat with an external application using the following information:

First, find your Facebook username by going to http://www.facebook.com/your_user/. Next, Open iChat, then select iChat » Preferences and click on the Accounts tab.

Click on the + (plus) sign to add a new account, with these settings:

* Account Type is Jabber Account
* Account name is your_user@chat.facebook.com, and enter

your password * Click the drop-down arrow to reveal Server options. Enter chat.facebook.com as the server name. * Enter 5222 as the port and click Done.

Click Done again, and you are good to go.

From reading this, it seems that it might be possible to telnet into facebook chat. I tried, but wasn't able to. Is it possible? How?

tony_sid

Posted 2011-03-08T06:06:06.977

Reputation: 11 651

Answers

6

There is no practical way to do this using a telnet client, as you would have to type all of the XML yourself, which is incredibly impractical. There are however several command-line XMPP clients available, as discussed in this stack overflow question.

List of Jabber Console Clients

If you are interested in learning about the XMPP protocol, I suggest you install Pidgin and take a look at the XMPP console by right-clicking on the Pidgin notification icon and choosing XMPP Console from the menu. All of the XMPP messages sent to and from your client will be shown, including every typing notification, status update, etc. It's very interesting to look at, and you can even try your hand at sending custom XMPP status codes from the console.

xmpp console pidgin

nhinkle

Posted 2011-03-08T06:06:06.977

Reputation: 35 057

Can someone please edit out the "123456" stuff? I had to add it in to get around a weird design flaw in this web site that required I change 6 more characters before accepting a correction I made to the format of the list of Jabber solutions. Thanks. – Randolf Richardson – 2011-03-08T06:28:54.330

1

@Randolf: The "design flaw" you are referring to is an intentional limit to prevent one-character edits.

– user1686 – 2011-03-08T12:43:44.750

2

From (very) limited testing, it seems possible.


Run telnet chat.facebook.com 5222 to connect, then proceed sending valid XML conforming to the Jabber protocol specification.

$ telnet chat.facebook.com 5222
Trying 69.63.181.105...
Connected to chat.facebook.com.
Escape character is '^]'.
<?xml version="1.0">
<stream>
// here I was looking up auth
Connection closed by foreign host.

Be aware that the server closes your connection within about a minute of inactivity, so looking up the protocol ad-hoc isn't practical. Or anything related to raw Jabber, as typing XML flawlessly isn't that easy, and once you send malformed XML, the connection closes immediately.

$ telnet chat.facebook.com 5222
Trying 69.63.181.105...
Connected to chat.facebook.com.
Escape character is '^]'.
<stream>
<?xml version="1.0"?><stream:stream id="5D13A2D5" from="chat.facebook.com" xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams" xml:lang="en"><stream:error><invalid-namespace xmlns="urn:ietf:params:xml:ns:xmpp-streams"/></stream:error></stream:stream>Connection closed by foreign host

If you want to suffer while chatting, a command-line client might be a better option. Alternatively, create a minimal client yourself, if it's about the protocol, so you don't have to type the XML under pressure -- and you don't suffer from the Telnet differences.

Daniel Beck

Posted 2011-03-08T06:06:06.977

Reputation: 98 421

How can I find out what the correct XML to send is? – tony_sid – 2011-03-08T06:20:20.753

2@OSXJedi By reading and understanding the Jabber protocol specification I linked to. Jabber is XML and even less intended for direct human use than FTP or IRC. You could also try to use another Jabber client and log your network traffic. That should give you an idea what to do based on a real example. – Daniel Beck – 2011-03-08T06:21:46.800

Actually I am trying to create a client for facebook chat. That's why I started tinkering around with telnet, so that I could understand how to communicate with the chat server. – tony_sid – 2011-03-08T06:28:04.943

2@OSXJedi Then the best thing to do is probably to log your network traffic when using another Jabber client, as well as reading the specs. You likely don't have the time and typing accuracy to do this well enough using telnet. You can always add a "raw XML" feature to your client software for debugging purposes that lets you (the user) type in the XML directly, and build additional user features on top of that, so that e.g. auth happens automatically. But telnet isn't the way to go. – Daniel Beck – 2011-03-08T06:31:31.110

How would I log the network traffic? Would Wireshark be good for this? – tony_sid – 2011-03-08T06:33:17.747

@OSXJedi Yes. You could also try the search function on this site, because it's been asked before. – Daniel Beck – 2011-03-08T06:34:42.930

@OSXJedi, @danielbeck you can actually see XMPP status and XML pieces using Pidgin if you want to play around with XMPP. No need to write any custom software or use a packet sniffer just to look around. See my answer above. – nhinkle – 2011-03-08T07:53:55.160

1

Using telnet probably won't work as well as you'd like it to -- you probably mean a "raw socket connection." If you know the Jabber protocol really really well, you can do it with PuTTY:

  • putty -raw chat.facebook.com 5222

The best thing to do is to just get a Jabber client and connect to the hostname chat.facebook.com with it.

Randolf Richardson

Posted 2011-03-08T06:06:06.977

Reputation: 14 002