Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am trying to write a script in python to connect to facebook chat. I am just not able to. Here is the code:

import xmpp
PASS = "password"



if not C.connect(("",5222)):
    raise IOError('Can not connect to server.')

if not C.auth(jid.getNode(),PASS):
    raise IOError('Can not auth with server.')

C.send(xmpp.protocol.Message("","Hello world from script",))

This is the error I get:

An error occurred while looking up

And this is the debugger output here.

Which shows that I do get authenticated (Line 136) , but still the message is not sent somehow. I am really stuck at this for days now.

share|improve this question

2 Answers 2

up vote 0 down vote accepted

As @grawity pointed out, you need to get the JIDs which you can get by adding following code to your script.

In your code after authenticating with server you can ask the server for the list of contacts. In your code add this,

rosterobject = C.getRoster()

If you want to just check/print the JIDs, you can do this with following loop.

for i in rosterobject.getItems():
    print i

In roster object you should have contacts aka JIDs, Now use that JID in the next statement,

C.send(xmpp.Message("jidfromrosterobj@domain.tld","Hello world from script",))

I hope this solves your problem.

share|improve this answer JIDs are only valid during authentication. For sending messages you have to use JIDs, which you can find out from your XMPP roster. (Sending a message to yourself does not work, though.)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.