如何从Facebook客户聊天插件中获取Referer_uri?

时间:2019-06-12 21:00:27

标签: javascript facebook facebook-customer-chat

我正在尝试从facebook customer chat plugin获取referer_uri。 我需要从用户与机器人聊天的地方获取网站的URL。我一次收到了Referer_uri,但之后却从有效载荷中消失了。

这是我得到的有效载荷:

{
  "object": "page",
  "entry": [
    {
      "id": "475156983235959",
      "time": 1560371380901,
      "messaging": [
        {
          "sender": {
            "id": "2092376807526537"
          },
          "recipient": {
            "id": "475156983235959"
          },
          "timestamp": 1560371379688,
          "postback": {
            "title": "CONTACT US",
            "payload": "CONTACT US",
            "referral": {
              "source": "CUSTOMER_CHAT_PLUGIN",
              "type": "OPEN_THREAD"
            }
          }
        }
      ]
    }
  ]
}

这是我收到的回发事件:

Event(baseEvent=PostbackEvent(super=BaseEvent(senderId=2092376807526537,
recipientId=475156983235959, 
timestamp=2019-06-12T20:29:39.688Z), 
title=CONTACT US, 
payload=Optional[CONTACT US],
referral=Optional[Referral(source=CUSTOMER_CHAT_PLUGIN, 
type=OPEN_THREAD, 
refPayload=Optional.empty, 
adId=Optional.empty)], 
priorMessage=Optional.empty))

我也尝试添加refdata-ref,但存在相同的问题,例如Referer_uri。

<div id="fb-root"></div>
<script>
  window.fbAsyncInit = function() {
    FB.init({
      xfbml            : true,
      version          : 'v3.3'
    });
  };

  (function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = 'https://connect.facebook.net/en_US/sdk/xfbml.customerchat.js';
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>

<div class="fb-customerchat"
  page_id="475156983235959"
  ref="myRef"
  referer_uri="URL website"
  data-ref="devRef" 
  theme_color="#fa3c4c"
  logged_in_greeting="Hi! Please click on the menu!"
  logged_out_greeting="Hi! Please click on the menu!">
</div>

如何使Referer_uri与每个用户有效负载一起返回?如果不可能,那么如何获取用户与机器人聊天的网站网址?

0 个答案:

没有答案