Skip to content

Error with getThreadMessages #350

Description

@codingJWilliams

Description of the problem

I get a key error when trying to use client.getThreadMessages

Code to reproduce

from fbchat import Client
from fbchat.models import *
import time
client = Client('redacted', 'redacted')

before = time.time()

hasMoreMessages = True
while hasMoreMessages:
    current = client.fetchThreadMessages(thread_id='1813947025313467', limit=20, before=before)
    print(len(current))
    print(current[0])
    break

Traceback

Traceback (most recent call last):
  File "C:/Users/Jay Williams/Desktop/scrapeee.py", line 10, in <module>
    current = client.fetchThreadMessages(thread_id='1813947025313467', limit=20, before=before)
  File "C:\Users\Jay Williams\AppData\Local\Programs\Python\Python37\lib\site-packages\fbchat\client.py", line 854, in fetchThreadMessages
    'before': before
  File "C:\Users\Jay Williams\AppData\Local\Programs\Python\Python37\lib\site-packages\fbchat\client.py", line 189, in graphql_request
    return self.graphql_requests(query)[0]
  File "C:\Users\Jay Williams\AppData\Local\Programs\Python\Python37\lib\site-packages\fbchat\client.py", line 180, in graphql_requests
    'queries': graphql_queries_to_json(*queries)
  File "C:\Users\Jay Williams\AppData\Local\Programs\Python\Python37\lib\site-packages\fbchat\client.py", line 141, in _graphql
    return graphql_response_to_json(content)
  File "C:\Users\Jay Williams\AppData\Local\Programs\Python\Python37\lib\site-packages\fbchat\graphql.py", line 361, in graphql_response_to_json
    rtn[int(key[1:])] = value['data']
KeyError: 'data'

Environment information

  • Python version 3.7
  • fbchat version 1.4.1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions