【问题标题】:How to show web views in messenger如何在 Messenger 中显示 Web 视图
【发布时间】:2017-08-15 07:35:52
【问题描述】:

我正在关注这个:https://developers.facebook.com/docs/messenger-platform/webview/sharing

我已经创建了自定义类:

[JsonObject(MemberSerialization.OptIn)]
        public class elements
        {
            [JsonProperty]
            public string title { get; set; }
            [JsonProperty]
            public string image_url { get; set; }
            [JsonProperty]
            public string subtitle { get; set; }
            [JsonProperty]
            public default_action default_action { get; set; }
            [JsonProperty]
            public buttons[] buttons { get; set; }
        }
        [JsonObject(MemberSerialization.OptIn)]
        public class default_action
        {

            [JsonProperty]
            public string type { get; set; }

            [JsonProperty]
            public string url { get; set; }
        }
        [JsonObject(MemberSerialization.OptIn)]
        public class buttons
        {

            [JsonProperty]
            public string type { get; set; }

            [JsonProperty]
            public string url { get; set; }

            [JsonProperty]
            public string title { get; set; }
        }

然后,在方法中:

elements e = new elements();

                    e.default_action.type = "web_url";
                    e.default_action.type = "https://www.youtube.com/watch?v=kOkQ4T5WO9E";
                    e.title = "title";

                    List<buttons> list = new List<buttons>();
                    buttons b = new buttons();
                    b.title = "button title";
                    b.type = "web_url";
                    b.url = "https://www.youtube.com/watch?v=kOkQ4T5WO9E";
                    list.Add(b);
                    e.buttons = list.ToArray();

                    msg.ChannelData = e;
                    msg.Text = "test";

但它会引发错误。在 bot 框架仪表板中看不到问题。 如何调试这个?

【问题讨论】:

标签: c# webview messaging botframework facebook-messenger-bot


【解决方案1】:

观看Microsoft Bot Framework .NET - Enrich your conversation with Facebook Messengers Webview 视频。它向您展示了如何利用 Facebook Messenger 扩展在您的 Bot Framework 聊天机器人中提供 Webview 体验。

视频演示代码为here

【讨论】:

  • 这是题外话。是否可以为此创建一些模板?为了避免每次都写所有东西?
  • 是的,您可以创建类,将它们放在不同的程序集中并在您的项目中引用该程序集。
猜你喜欢
  • 2017-02-01
  • 1970-01-01
  • 2019-09-15
  • 1970-01-01
  • 1970-01-01
  • 2012-01-23
  • 1970-01-01
  • 2017-02-13
  • 2014-03-08
相关资源
最近更新 更多