Facebook Messenger API:发送结构化消息 [英] Facebook Messenger API: Send Structured Message

查看:423
本文介绍了Facebook Messenger API:发送结构化消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

遵循此示例时.

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",
      }],
    }]
  }
}

我收到以下错误:

\错误\":{\消息\":\(#100)元素数据不完整:标题和至少一个其他字段(图像url,字幕或按钮)必须为非空值\" ,\类型\":\"OAuthException \",\代码\":100,\"fbtrace_id \":\"ElbXaF25 + 0G \"}

\"error\":{\"message\":\"(#100) Incomplete element data: title and at least one other field (image url, subtitle or buttons) is required with non-empty value\",\"type\":\"OAuthException\",\"code\":100,\"fbtrace_id\":\"ElbXaF25+0G\"}

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

Am I missing something? Looks to me that all the relevant fields are present.

推荐答案

弄清楚了,用ruby编写,我需要先在散列上调用to_json,然后再发送.

Figured it out, writing this in ruby and I needed to call to_json on the hash before sending it.

这篇关于Facebook Messenger API:发送结构化消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆