【问题标题】:How to send message to new user after user comment on a post用户对帖子发表评论后如何向新用户发送消息
【发布时间】:2019-07-06 19:39:17
【问题描述】:

当用户在 facebook 页面上发帖后,我需要向用户发送邀请消息。

步骤如下:

  1. 帖子中的用户 cmets
  2. 应用通过 webhook 收到评论通知
  3. 从评论中获取 psid
  4. 使用
  5. 通过 messenger 向 psid 发送邀请消息

messaging_type = MESSAGE_TAG 和 tag = NON_PROMOTIONAL_SUBSCRIPTION

如果用户之前曾通过 messenger 与页面进行过交互,则上述流程有效。

但是如果用户之前没有通过 messenger 与页面进行过交互,则发送消息 API 会失败并返回以下响应:

{"error":{"message":"(#551) 此人不可用 现在。","type":"OAuthException","code":551,"error_subcode":1545041,"fbtrace_id":"....."}}

尝试使用其他一些应用程序,例如许多聊天。它适用于上述场景中的新用户。

有人知道如何解决这个问题吗?

测试如下:


curl -X POST -d @test_message.json -H "Content-Type: application/json" 'https://graph.facebook.com/v3.3/me/messages?access_token=<page token>'

test_message.json:
{
  "messaging_type": "MESSAGE_TAG",
  "tag": "NON_PROMOTIONAL_SUBSCRIPTION",
  "recipient": {
    "id": "<psid of the user>"
  },
  "message": {
    "text": "This is a test"
  }
}

期待消息发送成功。

非常感谢。

【问题讨论】:

    标签: facebook-messenger


    【解决方案1】:

    想通了。应使用以下 API 向发表 Facebook 评论的用户发送消息:

    https://developers.facebook.com/docs/graph-api/reference/v3.3/object/private_replies

    【讨论】:

      猜你喜欢
      • 2012-01-22
      • 2016-05-27
      • 2020-07-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-07-25
      • 1970-01-01
      • 2012-05-01
      相关资源
      最近更新 更多