alexst07 / fbcomments

Simple script for downloading all facebook comments and their answers.
MIT License
3 stars 2 forks source link

Traceback from KeyError #1

Open bengan opened 6 years ago

bengan commented 6 years ago

Don't know much about json from facebook it looks as if "from" doesn't exist there. It crashes on every page I tried. This is the one I started with.

A certain facebook post

./fbcomments.py -a XXXXX -p https://www.facebook.com/daddario -i 10160256048450722 -f comments.txt

Traceback (most recent call last):
  File "./fbcomments.py", line 130, in <module>
    main()
  File "./fbcomments.py", line 124, in main
    res = list_comments(obj_id)
  File "./fbcomments.py", line 72, in list_comments
    ret_json += '"from":"' + obj["from"]["name"] + '",\n'
KeyError: 'from'
tomfbush commented 6 years ago

@bengan I think this is because FB reviewed the API and how much info you can get about users -- now the only account with which a "from" is associated is the page posting I believe.

If you change the code so that it only references obj['created_time'], obj['message'] and obj['id'] then it should work for you. I've made some very messy changes 'cos I needed this to work right now but it should only take a moment.