首页 文章

使用Python中的Facebook API Graph获取页面供稿

提问于
浏览
2

我正在尝试获取Facebook页面信息和提要/帖子,特别是每个帖子的文本 . 我在Facebook for Developers上注册了一个新的测试应用程序,我获得了客户端令牌,秘密令牌和ID . 我没有插入任何隐私链接或使用条款链接,因为它是个人测试 . 在Graph API Explorer中,我获得了应用访问令牌,我正在使用它 . 使用facebook-sdk我可以通过以下代码获取页面信息:

accessToken = "xxx"
user = 'BillGates'

graph = facebook.GraphAPI(accessToken, version='2.7')

profile = graph.get_object(id=user, fields='id,name,about,link,location,hometown,website', limit=100)

到目前为止,没问题 . 现在,我想要获得这个代码的帖子:

posts = graph.get_connections(profile['id'], connection_name='posts', fields='caption,created_time,description,from,link,message,object_id,parent_id,permalink_url,picture,privacy,place,properties,shares,source,status_type,story,to,type,with_tags', limit='100')

或在此网址上制作 request.get()

url = "https://graph.facebook.com/v2.7/BillGates?fields=feed{caption,created_time,description,from,link,message,object_id,parent_id,permalink_url,picture,source,status_type,type}&limit=100&access_token=xxx"

但我收到这个错误:

facebook.GraphAPIError: (#15) Requires session when calling from a desktop app

我的应用程序有联系电子邮件,是本机或计算机应用程序(它将在Linux服务器上运行),是公共的,只有电子邮件,public_profile和user_friend作为批准的元素 . 其他元素无法获得批准,因为我要填写笔记,但我无法填写它们 .

我的想法是定期请求“常规”访问令牌或我要分析的每个页面的访问令牌 .

任何帮助将不胜感激 .

1 回答

  • 1

    使用作为access_token已解决此问题

    url = "https://graph.facebook.com/v2.3/#{fb_id}/apprequests/?access_token=#{client_access_token}"
    

相关问题