Этот документ обновлен.
Перевод (Русский) еще не готов.
Последнее обновление (английский): 26 июн
Последнее обновление (Русский): 26 сен 2022 г.

URL Button Reference

The URL Button opens a webpage in the Messenger webview. This button can be used with the Button and Generic Templates.

If the site contains App Links the button will click into a native app. If you just made the change, you can use the Sharing Debugger to request a new scrape of the site.

For more information on using the URL button, see URL Button.

URL Button Syntax

Messenger Extensions SDK - Required Domain Whitelisting

Для отображения веб-страницы с включенным SDK расширений Messenger в режиме веб-просмотра Messenger необходимо занести домен (включая субдомен) в белый список в свойстве whitelisted_domains профиля Messenger вашего бота. Благодаря этому доступ к данным пользователя через функции SDK будет только у доверенных доменов.

Дополнительные сведения о занесении доменов в белый список см. в справке по whitelisted_domains.

{
  "type":"web_url",
  "url":"<URL_TO_OPEN>",
  "title":"<BUTTON_TEXT>",
  "webview_height_ratio": "<compact|tall|full>",
  "messenger_extensions": "<true|false>",  
  "fallback_url": "<URL_TO_FALLBACK_TO>"
}

URL Example Usage

curl -X POST -H "Content-Type: application/json" -d '{
  "recipient":{
    "id":"<PSID>"
  },
  "message":{
    "attachment":{
      "type":"template",
      "payload":{
        "template_type":"button",
        "text":"Try the URL button!",
        "buttons":[
          {
            "type":"web_url",
            "url":"https://www.messenger.com/",
            "title":"URL Button",
            "webview_height_ratio": "full"
          }
        ]
      }
    }
  }
}' "https://graph.facebook.com/v21.0/me/messages?access_token=<PAGE_ACCESS_TOKEN>"

URL Example Response

{
  "recipient_id": "1254477777772919",
  "message_id": "AG5Hz2Uq7tuwNEhXfYYKj8mJEM_QPpz5jdCK48PnKAjSdjfipqxqMvK8ma6AC8fplwlqLP_5cgXIbu7I3rBN0P"
}  

URL Properties

Property Type Description

type

String

Type of button. Must be web_url.

title

String

Button title. 20 character limit.

url

String

This URL is opened in a mobile browser when the button is tapped. Must use HTTPS protocol if messenger_extensions is true.

webview_height_ratio

String

Optional. Height of the Webview. Valid values: compact, tall, full. Defaults to full.

messenger_extensions

Boolean

Optional. Must be true if using Messenger Extensions.

fallback_url

String

The URL to use on clients that don't support Messenger Extensions. If this is not defined, the url will be used as the fallback. It may only be specified if messenger_extensions is true.

webview_share_button

String

Optional. Set to hide to disable the share button in the Webview (for sensitive info). This does not affect any shares initiated by the developer using Extensions.