【问题标题】:Facebook Messenger Bot - Invalid URL button fields for List TemplateFacebook Messenger Bot - 列表模板的 URL 按钮字段无效
【发布时间】:2018-05-12 18:48:56
【问题描述】:

我一直在努力向用户发送包含一些数据的列表。我正在关注facebook's doc 来设置我的请求有效负载。但是,我收到以下错误:

{'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/'}}]}}}} 

我已经检查过,多次重新检查过。另外,我已经从文档中发送了 facebook 的示例 json,但我得到了相同的回复。请看一下,让我知道我卡在哪里!

这是我的最终网址: "https://graph.facebook.com/v2.6/me/messages?access_token="

提前致谢!

【问题讨论】:

  • 按钮 url 字段中仅允许使用 whitelisted_domains。让我知道这是否解决了?
  • 我将 messenger_extension 禁用为 false。仅当它为 true 时才需要列入白名单的域。

标签: django facebook facebook-graph-api chatbot facebook-messenger-bot


【解决方案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": "@987654321@", "messenger_extensions": "false", "webview_height_ratio": "full" }], "default_action": { "type": "web_url", "url": "@987654322@", "messenger_extensions": "false", "webview_height_ratio": "full" } }, { "title": "Hello 2", "subtitle": "Subtitle 2", "image_url": "@987654323@*Vkf6A8Mb0wBoL3Fw1u0paA.jpeg", "buttons": [{ "title": "View", "type": "web_url", "url": "@987654324@", "messenger_extensions": "false", "webview_height_ratio": "full" }], "default_action": { "type": "web_url", "url": "@987654325@", "messenger_extensions": "false", "webview_height_ratio": "full" } } ] } } } }

【讨论】:

  • 乐于助人 =)
猜你喜欢
  • 1970-01-01
  • 2017-02-05
  • 2017-06-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-09-03
相关资源
最近更新 更多