Error getting user id from messenger webview even

2019-08-04 04:38发布

问题:

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


标签: php messenger