I have a simple sleekxmpp messaging bot that sends facebook messages (source: http://sleekxmpp.com/getting_started/sendlogout.html):
class SendMsgBot(sleekxmpp.ClientXMPP):
def __init__(self, jid, password, recipient, message):
sleekxmpp.ClientXMPP.__init__(self, jid, password, sasl_mech='X-FACEBOOK-PLATFORM')
self.recipient = recipient
self.msg = message
self.add_event_handler("session_start", self.start)
def start(self, event):
self.send_presence()
self.get_roster()
self.send_message(mto=self.recipient,
mbody=self.msg,
mtype='chat')
self.disconnect(wait=True)
I use this test script to send try out message:
from split.apps.sapi.utils import SendMsgBot
jid = '[email protected]'
to = '[email protected]'
msg = "Try out message"
xmpp = SendMsgBot(jid, None, to, msg)
xmpp.credentials['access_token'] = [access token provided by Graph API]
xmpp.credentials['api_key']= [API key of our application]
xmpp.auto_reconnect = True
if xmpp.connect(('chat.facebook.com', 5222)):
xmpp.process(block=True)
My problem is that it doesn't send messages when I don't provide my correct facebook password. Hardcoding the authentification mechanism to sasl_mech='X-FACEBOOK-PLATFORM' didn't help. When I add correct password to SendMsgBot initialization, it sends messages without any problems:
xmpp = SendMsgBot(jid, password, to, msg)
Asking the user of the application to provide the facebook password is nonsense, I think the access token and facebook id should be enough to make this work.