【问题标题】:Facebook - Get conversation thread ID with message ID?Facebook - 使用消息 ID 获取对话线程 ID?
【发布时间】:2017-08-17 03:27:48
【问题描述】:

当我从 Facebook Realtime API (webhook) 收到“收到消息的回调”事件时,我想获取对话中以前的消息。为此,我需要对话线程的 ID。

https://developers.facebook.com/docs/messenger-platform/webhook-reference/message?locale=en_US

该事件不包含有关对话线程 ID (t_id) 的任何信息。它只包含消息 ID (mid)。

https://developers.facebook.com/docs/graph-api/reference/v2.8/conversation

有没有办法获取对话线程 ID?

【问题讨论】:

  • 我在这里看到了类似的讨论:stackoverflow.com/questions/19129017/…
  • 遗憾的是,这并没有帮助。 “自 2016 年 8 月 8 日起,FQL 将不再可用且无法查询。”我只使用 Graph API。
  • 也有这个问题!
  • @John,你有什么收获吗?
  • 遗憾的是我还没有找到解决方案。

标签: facebook facebook-graph-api facebook-webhooks


【解决方案1】:

我觉得有一种更简单的方法可以做到这一点。您可以在对话中使用 user_id 过滤器:

https://graph.facebook.com/v3.0/--PAGE-ID--/conversations?fields=senders&user_id=

从这里查看参数部分:https://developers.facebook.com/docs/graph-api/reference/page/conversations/

【讨论】:

  • 感谢它拯救了我的一天
【解决方案2】:

没有直接的方法。您可以使用以下解决方法来循环对话 ID:

(a) 获取发件人 ID https://graph.facebook.com/v3.0/--PAGE-ID--/conversations?fields=senders 的所有对话 ID

(b) 查找消息发送者的 user_id。 https://graph.facebook.com/v3.0/--MESSAGE-ID--?fields=from

(c) 遍历对话 id 以查找消息 user_id 的匹配项并获取 thread_id。

PS:这是一个昂贵的解决方案。除非你真的需要,否则尽量避免它。

【讨论】:

    猜你喜欢
    • 2014-02-01
    • 2018-09-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-22
    相关资源
    最近更新 更多