Бот Facebook Messenger — недопустимые поля кнопки URL для шаблона списка

Я работаю над отправкой списка пользователю, содержащего некоторые данные. Я следую документу facebook, чтобы настроить полезную нагрузку моего запроса . Однако я получаю следующую ошибку:

{'error': {
    'message': '(#100) Invalid URL button fields provided. Please check documentation for details.', 
    'type': 'OAuthException', 
    'code': 100, 
     'error_subcode': 2018125, 'fbtrace_id': 'GZFFcM+j5e/'}} 

Вот моя полезная нагрузка JSON:

{'recipient': {'id': 'MY_MESSENGER_ID'}, 
 'message':
    {'attachment': 
       {'type': 'template', 
        'payload': 
          {'template_type': 'list', 
           'top_element_style': 'compact', 
            'elements': 
                [{'title': 'Hello 1', 'subtitle': 'Subtitle 1', 
                 'buttons': 
                    [{'title': 'View', 'type': 'web_url', 
                      'url': 'https://www.medium.com/', 
                      'messenger_extensions': 'false', 
                      'webview_height_ratio': 'full',
                      'fallback_url': 'https://www.medium.com/'}],
                 'default_action': 
                    {'title': 'View', 'type': 'web_url', 
                    'url': 'https://www.medium.com/',
                    'messenger_extensions': 'false', 
                    'webview_height_ratio': 'full', 
                    'fallback_url': 'https://www.medium.com/'}}, 
              {'title': 'Hello 2', 'subtitle': 'Subtitle 2', 
               'image_url': 'https://cdn-images-1.medium.com/1*Vkf6A8Mb0wBoL3Fw1u0paA.jpeg', 
               'buttons': 
                      [{'title': 'View', 'type': 'web_url', 
                         'url': 'https://www.medium.com/',
                         'messenger_extensions': 'false', 
                         'webview_height_ratio': 'full', 
                         'fallback_url': 'https://www.medium.com/'}], 
               'default_action': 
                      {'title': 'View', 'type': 'web_url', 
                       'url': 'https://www.medium.com/', 
                       'messenger_extensions': 'false',
                       'webview_height_ratio': 'full', 
                       'fallback_url': 'https://www.medium.com/'}}]}}}} 

Я проверял, перепроверял несколько раз. ПЛЮС, я отправил пример json на facebook из документа, но получил тот же ответ. Пожалуйста, посмотрите и дайте мне знать, где я застрял!

Это мой конечный URL: "https://graph.facebook.com/v2.6/me/messages?access_token="

Заранее спасибо!


person O_o    schedule 29.11.2017    source источник
comment
Только whitelisted_domains разрешено в полях URL кнопки. дайте мне знать, если это решает?   -  person Raja Simon    schedule 29.11.2017
comment
Я отключил messenger_extension на false. Домен в белом списке нужен только в том случае, если это правда.   -  person O_o    schedule 29.11.2017


Ответы (1)


В вашем запросе есть две проблемы:

  • Для default_action можно установить fallback_url, только если messenger_extensions:true
  • default_action не может иметь реквизит title.

Попробуй это:

{ "recipient": { "id": "{{PSID}}" }, "message": { "attachment": { "type": "template", "payload": { "template_type": "list", "top_element_style": "compact", "elements": [{ "title": "Hello 1", "subtitle": "Subtitle 1", "buttons": [{ "title": "View", "type": "web_url", "url": "https://www.medium.com/", "messenger_extensions": "false", "webview_height_ratio": "full" }], "default_action": { "type": "web_url", "url": "https://www.medium.com/", "messenger_extensions": "false", "webview_height_ratio": "full" } }, { "title": "Hello 2", "subtitle": "Subtitle 2", "image_url": "https://cdn-images-1.medium.com/1*Vkf6A8Mb0wBoL3Fw1u0paA.jpeg", "buttons": [{ "title": "View", "type": "web_url", "url": "https://www.medium.com/", "messenger_extensions": "false", "webview_height_ratio": "full" }], "default_action": { "type": "web_url", "url": "https://www.medium.com/", "messenger_extensions": "false", "webview_height_ratio": "full" } } ] } } } }

person amuramoto    schedule 30.11.2017
comment
Рад помочь =) - person amuramoto; 25.07.2018