简体   繁体   English

如何在Facebook API v2.4及更高版本上获取收件人ID(RestFB / Facebook4J)

[英]How to get the recipient ID on Facebook API v2.4 and newer (RestFB/Facebook4J)

I'm trying to send messages to customers who want to know the current state of their order. 我正在尝试向想要了解订单当前状态的客户发送消息。 Now I know that you can only send messages to someone who sent you a message because you need to have the specific recipient ID. 现在我知道您只能向发送邮件的人发送邮件,因为您需要具有特定的收件人ID。 The problem with this is that if I want to get the recipient ID I need to read my mailbox and therefore need the permission: read_mailbox. 这样做的问题是,如果我想获取收件人ID,我需要读取我的邮箱,因此需要权限:read_mailbox。 But read_mailbox is deprecated as of Facebook API v2.4 and newer. 但自Facebook API v2.4及更新版本起,不推荐使用read_mailbox。 I don't think that it is impossible to do it though. 我不认为这是不可能做到的。 Question beeing, how to do it with v2.4 or newer? 问题,如何使用v2.4或更新版本?

Edit: Thanks CBroe for the answer Last problem now is that when I get a specific message it only gives me the created_time and the id back. 编辑:感谢CBroe的答案现在最后一个问题是,当我收到一条特定的消息时,它只给了我created_time和id。 Same thing when I try it with the GraphAPI Explorer 当我使用GraphAPI Explorer尝试它时也是如此

This: 这个:

JsonObject message = getFacebookClient().fetchObject("m_mid.1467893842385:ae7475981839704062", JsonObject.class);

Gives this: 给出这个:

{
  "created_time": "2016-07-07T12:17:22+0000",
  "id": "m_mid.1467893842385:ae7475981839704062"
}

What am I doing wrong? 我究竟做错了什么? Am I missing a parameter or a permission? 我错过了参数或权限吗?

No, this doesn't need read_mailbox permission. 不,这不需要read_mailbox权限。

https://developers.facebook.com/docs/graph-api/reference/page/conversations#read : https://developers.facebook.com/docs/graph-api/reference/page/conversations#read

A page access token with read_page_mailboxes permission is required. 需要具有read_page_mailboxes权限的页面访问令牌

So you have to ask for that permission, plus manage_pages of course (because you need the latter to get a page access token.) 所以你必须要求这个权限,当然还有manage_pages (因为你需要后者来获取页面访问令牌。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM