首页 > 解决方案 > 我无法使用 Python 和 fbchat 作为聊天机器人登录到我的 Facebook 帐户

问题描述

这是我的代码:

from fbchat import Client, log
from fbchat.models import *

Email = '****'
Password = '****'

class Jervis(Client):

    def onMessage(
            self,
            mid=None,
            author_id=None,
            message=None,
            message_object=None,
            thread_id=None,
            thread_type=ThreadType.USER,
            ts=None,
            metadata=None,
            msg=None,
            **kwargs
    ):
        self.markAsRead(author_id)
        log.into("Message {} from {} in {}".format(message_object, thread_id, thread_type))
        msgText = message_object.text

        reply = "hello, i'm leonel"

        if author_id != self.uid:
            self.send(Message(text=reply), thread_id, thread_type=thread_type)

        self.markAsRead(author_id, thread_id)



client = Jervis(email= Email, password= Password)
client.listen()

这是我得到的错误:

Attempt #1 failed, retrying
Traceback (most recent call last):
  File "C:\Users\nmzub\AppData\Local\Programs\Python\Python39\lib\site-packages\fbchat\_client.py", line 205, in login
    self._state = State.login(
  File "C:\Users\nmzub\AppData\Local\Programs\Python\Python39\lib\site-packages\fbchat\_state.py", line 153, in login
    raise _exception.FBchatUserError(
fbchat._exception.FBchatUserError: Login failed. Check email/password. (Failed on url: https://m.facebook.com/login/?email=nmzubayeralam%40gmail.com&cuid=AYi9BVk7M1mLfuwkBYpPmyt9BVGFy1ap622CkGSZBOYf4BHSSM37rIhOWewqwnHj71hLpWdmq_gxCwBMrcCny-5RdF34vZFGDJecmjC4HaXfYXNuUlNhAuilo-ZKkvrVGCCR5rsOn5zfna0lzZx2kXGwtz13F_Pkn3FEmW214vFT0JiE-4t-E8WlAWAA3LLfFjjMnE6SmGWDvMm5PhrQAeddGMCnmAqZmNaQVUEbxesTz2fR2Nfv21-_kQMJmyqPHBYjOAniWnOvpjsDzGPVoleEqWPUeWM6mVTRW3taVSpsRg&li=ZYx9YQ1i7Ee6FaHjRwq6wiXb&e=1348060&shbl=1&refsrc=deprecated&_rdr)
Attempt #2 failed, retrying

标签: pythonfacebookchatbotmessenger

解决方案


推荐阅读