fbchat-dev / fbchat

Facebook Chat (Messenger) for Python
https://fbchat.readthedocs.io
BSD 3-Clause "New" or "Revised" License
1.19k stars 412 forks source link

Error while getting latest messages #38

Closed pinghajen closed 7 years ago

pinghajen commented 8 years ago

I am getting this error

Logging in... Traceback (most recent call last): File "C:\Users\jerem\Source\Repos\FBChatBot\FBChatBot\FBChatBot\FBChatBot.py", line 8, in last_messages = client.getThreadInfo(bot["chatID"],0) File "C:\Users\jerem\AppData\Local\Programs\Python\Python35\lib\site-packages\fbchat-0.3.1-py3.5.egg\fbchat\client.py", line 266, in getThreadInfo for message in j['payload']['actions']: KeyError: 'actions' Press any key to continue . . .

and this is my code

import fbchat, json

with open("data/user.json") as user: bot = json.load(user)

client = fbchat.Client(bot["username"], bot["password"])

last_messages = client.getThreadInfo(bot["chatID"],0)

pinghajen commented 8 years ago

edit: I tried passing the chatID as an integer also

pinghajen commented 8 years ago

If I edit the code to print out j['payload'] and the returned json is this

{'message_blocked_ids': [], 'payload_source': 'server_fetch_thread_info', 'end_of_history': [{'type': 'user', 'id': 890328284337788, 'fbid': '890328284337788'}], 'roger': None }

it doesn't seem to have an actions element

afonsocarlos commented 8 years ago

Is this chatID a user id apart from yours?

madsmtm commented 7 years ago

Facebook has changed a lot of things, and fbchat has been updated, so I'm assuming this is outdated ;)