1 回答
TA贡献1804条经验 获得超2个赞
和 elements属性buttons需要是列表。看看下面的示例模板。
var attachment = new
{
type = "template",
payload = new
{
template_type = "generic",
elements = new []
{
new {
title = "title",
image_url = "https://thechangreport.com/img/lightning.png",
subtitle = "subtitle",
buttons = new object[]
{
new {
type = "element_share",
share_contents = new {
attachment = new {
type = "template",
payload = new
{
template_type = "generic",
elements = new []
{
new {
title = "title 2",
image_url = "https://thechangreport.com/img/lightning.png",
subtitle = "subtitle 2",
buttons = new object[]
{
new {
type = "web_url",
url = "http://m.me/petershats?ref=invited_by_24601",
title = "Take Quiz"
},
},
},
},
},
}
},
},
},
},
},
},
};
reply.ChannelData = JObject.FromObject(new { attachment });
share_contents请注意,如果您的主模板与您尝试共享的模板不同,您只需向模板添加一个元素。否则,您的按钮只能是new { type = "element_share" },这使得模板变得不那么复杂。
此外,请务必将您的所有 URL列入白名单,并确保所有图像 URL 都能正常工作——其中有几个不能正常工作。如果 URL 未列入白名单且图像链接已损坏,则模板不会呈现。
- 1 回答
- 0 关注
- 89 浏览
添加回答
举报