0

我试图从我的机器人的webview分享。这里是我的代码“image_aspect_ratio”国旗不受尊重时,从信使分享BOT 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

您需要在您的有效载荷增加"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" 
      } 
      ] 
     } 
     ] 
    } 
    } 
}