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

青春壹個敷衍的年華 提交于 2019-12-11 06:17:42

问题


i have white listed my domain and i get a message showing it was successful

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

but when i try getting the user id I get the error message

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

i am using A PC so an outdated version might not be it, and i have the messenger extension set this way

$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?

回答1:


one of the Admins at the messenger platform community just confirmed that webviews extension don't work on PC, so the only way i can get the User ID is by adding it to the URL on the URL button or through session variables.




回答2:


I don't think that is a valid json format. It should be in double quotes not single quotes. Why don't you write in php array instead and convert to json to reduce your chances of making mistakes.

eg.

$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);


来源:https://stackoverflow.com/questions/43589797/error-getting-user-id-from-messenger-webview-even-after-white-listing-domain

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!