【问题标题】:facebook messenger api, templates doesn't worksfacebook messenger api,模板不起作用
【发布时间】:2017-09-09 19:09:00
【问题描述】:

当我使用 PHP curl 将此 json 数据发送到 Facebook Messenger Bot api 时,它工作正常。

$jsonData = '{ “接受者”:{ "id":"'.$sender.'" }, “信息”:{ “文本”:“'.$obj.'” } }';

但是,当我使用 FB 页面中的模板时。模板不起作用

$jsonData = '{
  "recipient":{
    "id":"'.$sender.'"
  },
  "message":{
    "attachment":{
      "type":"template",
      "payload":{
        "template_type":"generic",
        "elements":[
           {
            "title":"Hello",
            "image_url":"http://icons.iconarchive.com/icons/paomedia/small-n-flat/1024/sign-check-icon.png",
            "subtitle":"Title",
            "default_action": {
              "type": "web_url",
              "url": "https://google.com",
              "messenger_extensions": true,
              "webview_height_ratio": "tall",
              "fallback_url": "https://google.com/"
            },
            "buttons":[
              {
                "type":"web_url",
                "url":"https://google.com",
                "title":"View Website"
              },{
                "type":"postback",
                "title":"Start Chatting",
                "payload":"DEVELOPER_DEFINED_PAYLOAD"
              }              
            ]      
          }
        ]
      }
    }
  }
}';

我正在尝试编码为 Json,替换按钮,没有任何反应。 Facebook 模板在 Messenger 更新后不起作用,或者我需要使用新参数?

【问题讨论】:

    标签: json facebook api curl bots


    【解决方案1】:

    确保:

    1:google.com 在您的白名单中。
    2:它的HTTPS但不是HTTP

    否则你会得到这样的错误

    {"error":{"message":"(#100) The URL provided is not whitelisted for messenger extensions","type":"OAuthException","code":100,"error_subcode":2018062,"fbtrace_id":"GNd1AXlQsjz"}}
    

    我猜如果你删除 default_aciton 它会起作用:)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-02
      • 2019-04-21
      • 2018-03-05
      • 1970-01-01
      • 2015-09-22
      相关资源
      最近更新 更多