0

我正在尝试从 Facebook 群组中提取所有帖子。我按照 2017 年帖子中的示例安装了 facepy:

import csv
from datetime import datetime
from facepy import GraphAPI
import json

APP_TOKEN = r'XXXMYTOKENXXX'

graph = GraphAPI(APP_TOKEN)

groupIDs = ("2208833392") #https://www.facebook.com/groups/TheEntomologyGroup/ has Facebook Group ID 2208833392

now = datetime.now() # current date and time
date_time = now.strftime("%Y%m%d%H%M%S")

outfile_name = date_time+"TheEntomologyGroup.csv"
f = csv.writer(open(outfile_name, "wb+"))

for gID in groupIDs:
    groupData = graph.get(gID + "/feed", page=True, retry=1, limit=500)

    for data in groupData:
        json_data=json.dumps(data, indent = 4,cls=DecimalEncoder)
        decoded_response = json_data.decode("UTF-8")
        data = json.loads(decoded_response)
        print("Paging group data...")

        for item in data["data"]:
            print(item)

...但我收到一个错误:

FacebookError: [100] Unsupported get request. Object with ID '2' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api

问题:

  1. facepy 仍然是用于此类事情的最佳/最简单的库吗?
  2. 我究竟做错了什么?有什么建议么?
4

1 回答 1

0

我现在看到我从原始帖子复制的示例中的语法错误:

groupIDs = ("2208833392")

本来应该

groupIDs = [“2208833392”]

不过,我仍然遇到错误,并且希望获得有关实现我想要做的最佳方式的任何建议。谢谢!

错误:“需要具有授予 managed_group 权限的管理员或使用已安装应用程序的成员”

于 2021-12-29T15:08:36.620 回答