Facebook Messenger API:发送结构化消息

问题描述 投票:3回答:2

关注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)不完整的元素数据:标题和至少一个其他字段(图片网址,字幕或按钮)是非空值\”,\“类型\ “:\” OAuthException \”,\ “代码\”:100,\ “fbtrace_id \”:\ “ElbXaF25 + 0G \”}

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

facebook bots facebook-messenger
2个回答
3
投票

想出来,用红宝石写这个,我需要在发送之前在哈希上调用to_json


1
投票

是的,在发送之前需要转换为json格式要么是结构化消息,要么是短信。

© www.soinside.com 2019 - 2024. All rights reserved.