【问题标题】:Facebook Messenger API: Send Structured MessageFacebook Messenger API:发送结构化消息
【发布时间】:2016-08-06 16:15:18
【问题描述】:

当关注this example时。

messageData = {
"attachment": {
  "type": "template",
  "payload": {
    "template_type": "generic",
    "elements": [{
      "title": "First card",
      "subtitle": "Element #1 of an hscroll",
      "image_url": "http://messengerdemo.parseapp.com/img/rift.png",
      "buttons": [{
        "type": "web_url",
        "url": "https://www.messenger.com/",
        "title": "Web url"
      }, {
        "type": "postback",
        "title": "Postback",
        "payload": "Payload for first element in a generic bubble",
      }],
    },{
      "title": "Second card",
      "subtitle": "Element #2 of an hscroll",
      "image_url": "http://messengerdemo.parseapp.com/img/gearvr.png",
      "buttons": [{
        "type": "postback",
        "title": "Postback",
        "payload": "Payload for second element in a generic bubble",
      }],
    }]
  }
}

我收到以下错误:

\"error\":{\"message\":\"(#100) 不完整的元素数据:标题和至少一个其他字段(图片url、副标题或按钮)需要非空值\" ,\"type\":\"OAuthException\",\"code\":100,\"fbtrace_id\":\"ElbXaF25+0G\"}

我错过了什么吗?在我看来,所有相关字段都存在。

【问题讨论】:

标签: facebook bots facebook-messenger


【解决方案1】:

是的,发送前需要转换成json格式,要么是结构化消息,要么是文本消息。

【讨论】:

    【解决方案2】:

    想通了,用 ruby​​ 写了这个,我需要在发送之前在哈希上调用to_json

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-02-14
    • 2016-08-11
    • 2021-05-04
    • 1970-01-01
    • 1970-01-01
    • 2017-10-06
    • 2017-06-04
    相关资源
    最近更新 更多