首页 > 解决方案 > 使用 Facebook Graph API 进行私人回复

问题描述

我制作了一个机器人,它可以监控评论并找出哪个是最新评论并且效果很好。我试图添加一个功能,我可以将 private_replies 发送给发表评论的用户,我检查了所有文档并在互联网上搜索,但我仍然感到困惑,我应该怎么做?

def monitor_comment():
    print("Bot is monitoring comments")
    #Getting the data from fb
    comment_data = graph.get_connections(COMBINED_POST_ID_TO_MONITOR,"comments",order='reverse_chronological')
    commends = []
    for comment in comment_data['data'][:10]:
        commends.append (comment)
    #Configure it so that i can take the first line of 'id'
    data = commends[0]['id']
    #Convert data to string cuz it doesn't work for some reason
    data_converted = str(data)
    return data_converted
#This is where it private_reply to the commend_id from above
def private_reply(comment_id):
    #AM CONFUSE HERE
    private_reply = graph.put_object(comment_id,"conversations",  message= "Hello This is a test")
    return private_reply

标签: pythonfacebook-graph-apifacebook-sdk-4.0

解决方案


推荐阅读