在不提供密码的情况下,用sleekxmpp发送facebook消息

2024-05-15 03:16:32 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个简单的sleekxmpp消息传递机器人,它可以发送facebook消息(来源:http://sleekxmpp.com/getting_started/sendlogout.html):

类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)

我使用此测试脚本发送试用消息:

^{pr2}$

我的问题是,当我没有提供正确的facebook密码时,它不会发送消息。将身份验证机制硬编码到saslüu mech='X-FACEBOOK-PLATFORM'没有帮助。当我在SendMsgBot初始化中添加正确的密码时,它会毫无问题地发送消息:

xmpp = SendMsgBot(jid, password, to, msg)

要求应用程序的用户提供facebook密码是无稽之谈,我认为访问令牌和facebook id应该足够让这项工作起作用。在


Tags: self消息密码messagefacebookinitdefjid

热门问题