即使在将域列入白名单后,从 Messenger webview 获取用户 ID 时仍出错

Error getting user id from messenger webview even after white listing domain

我已将我的域列入白名单,我收到一条消息显示它已成功

{"result": "Successfuly updated whitelisted domains"}

但是当我尝试获取用户 ID 时收到错误消息

An error occuredMessenger Extensions are not enabled - could be "messenger_extensions" was not set on a url, the domain was not whitelisted or this is an outdated version of Messenger client

我使用的是 A PC,所以可能不是过时的版本,我以这种方式设置了 Messenger 扩展程序

$get_started_display = "{
'recipient':{
'id': $sender_id
},
'message':{
'attachment':{
  'type':'template',
  'payload':{
    'template_type':'button',
    'text':'Click a button below to continue',
    'buttons':[

      {
        'type':'web_url',
        'title':'Add Leader Profile',
        'url':'https://aadb-3120.herokuapp.com/login.html',
        'webview_height_ratio' : 'full',
        'messenger_extensions': true
      },
      {
        'type':'postback',
        'title':'Review Added Profile',
        'payload':'review'
      },

      {
        'type':'postback',
        'title':'Help',
        'payload':'help'
       },
     ]
   }
  }
 }
}";
please what are my doing wrong?

我认为这不是有效的 json 格式。它应该用双引号而不是单引号。你为什么不写成 php 数组并转换成 json 来减少你犯错误的机会。

例如

$data = [
'recipient' => [
    'id' => $sender_id
],
'message' => [
    'attachment' => [
        'type' => 'template',
        'payload' => [
            'template_type' => 'button',
            'text' => 'Click a button below to continue',
            'buttons' => [
                [
                    'type' => 'web_url',
                    'url' => 'https://google.com',
                    'title' => 'Visit Google',
                    "webview_height_ratio" => "compact"
                ]
            ]
        ]
    ]
]];


$json = json_encode($data);

messenger 平台社区的一位管理员刚刚确认 webviews 扩展在 PC 上不起作用,所以我获得用户 ID 的唯一方法是将其添加到 URL URL 按钮或通过会话变量。