使用python sd读取facebook消息

2024-05-20 09:38:40 发布

您现在位置:Python中文网/ 问答频道 /正文

我试着用python脚本阅读facebook上的对话。用这个密码

import facebook

at = "page access token"
pid = "page id"
api = facebook.GraphAPI( at )
p = api.get_object( 'me/conversations')
print p

我得到一本字典,里面有

{'paging': {'next': 'https://graph.facebook.com/v2.5/1745249635693902/conversations?access_token=<my_access_token>&limit=25&until=1454344040&__paging_token=<my_access_token>', 'previous': 'https://graph.facebook.com/v2.5/1745249635693902/conversations?access_token=<my_access_token>&limit=25&since=1454344040&__paging_token=<my_access_token>'}, 'data': [{'link': '/Python-1745249635693902/manager/messages/?mercurythreadid=user%3A100000386799941&threadid=mid.1454344039847%3A2e3ac25e0302042916&folder=inbox', 'id': 't_mid.1454344039847:2e3ac25e0302042916', 'updated_time': '2016-02-01T16:27:20+0000'}]}

那些田地是什么?我怎样才能收到短信?

编辑:我试图通过添加

    msg = api.get_object( p['data'][0]['id']+'/messages')
    print msg

但它只返回相同的字段。我在API文档中搜索了一段时间,但没有发现任何有用的东西。甚至可以使用python读取facebook页面对话的消息内容吗?


Tags: httpstokenapiidgetfacebookobjectaccess