我正在尝试从我的机器人的webview中分享。这是我的代码
var messageToShare = {
"attachment":{
"type":"template",
"payload":{
"template_type":"generic",
"image_aspect_ratio":"square",
"elements":[
{
"title":"Welcome to Peter\'s Hats",
"subtitle":"We\'ve got the right hat for everyone.",
"image_url":"https://pbs.twimg.com/profile_images/735453447718338561/9W-MTtOo_400x400.jpg",
"buttons":[
{
"type":"web_url",
"url": "my share url",
"title":"View Website"
}
]
}
]
}
}
}
MessengerExtensions.beginShareFlow(
function success() {},
function error(errorCode, errorMessage) {},
messageToShare,
"broadcast"
);
共享正在运行,但它没有按预期发布图像。不尊重“image_aspect_ratio”标志,图像以水平布局显示。
但是当通过CURL完成共享时,相同的JSON将图像显示为正方形。我的共享对象有问题吗?请帮忙
答案 0 :(得分:1)
这是Messenger平台上的一个错误。我向Facebook报道了它,现在已经修好了。 https://developers.facebook.com/bugs/391245647960177/
答案 1 :(得分:0)
您需要在有效负载中添加"sharable":true
:
var messageToShare = {
"attachment":{
"type":"template",
"payload":{
"template_type":"generic",
"image_aspect_ratio":"square",
"sharable": true,
"elements":[
{
"title":"Welcome to Peter\'s Hats",
"subtitle":"We\'ve got the right hat for everyone.",
"image_url":"https://pbs.twimg.com/profile_images/735453447718338561/9W-MTtOo_400x400.jpg",
"buttons":[
{
"type":"web_url",
"url": "my share url",
"title":"View Website"
}
]
}
]
}
}
}