【问题标题】:Error getting user id from messenger webview even after white listing domain即使在白名单域之后从信使 webview 获取用户 ID 时出错
【发布时间】:2017-04-24 13:42:55
【问题描述】:

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

{"result": "成功更新白名单域"}

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

发生错误未启用 Messenger 扩展 - 可能是未在 url 上设置“messenger_extensions”、域未列入白名单或这是 Messenger 客户端的过时版本

我使用的是 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?

【问题讨论】:

标签: php messenger


【解决方案1】:

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

【讨论】:

    【解决方案2】:

    我认为这不是有效的 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);
    

    【讨论】:

    • 感谢您的宝贵时间,这也有效,@the messenger 平台社区的一位管理员刚刚向我确认,messenger webviews 在 PC 上不起作用,所以我必须将 user_id 添加到 URL,或者将其存储在会话变量中。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多