The translation was generated automatically and may contain mistakes

Annex

The app widget will allow you to add to your site in one click the ability to quickly go to the game from the VKontakte directory.

Use a full application card or a compact button, show users playing friends — the widget will fit neatly into any design and attract new players.

Please note that the community application URL must be specified in the format https://vk.ru/app123456_-654321 . For such applications, only the type of "Button" is available. "

Connecting Widget

To add an app widget to your site, follow these three steps:

In the tag <head> On your website, add a link.. openapi.js :

HTML
<script src="https://vk.ru/js/api/openapi.js?169" type="text/javascript"></script>

Add an element to the body of the page <div> , which will display comments, give it a unique id, and add a widget initialization code to it. For example:

HTML
<div id="vk_app_5327745"></div> <script type="text/javascript"> VK.Widgets.App('vk_app_5327745', 5327745); </script>

If your site is already in use Open API , adding a widget is even easier. Simply add widget initialization.

Additional settings

Widget creation method VK.Widgets.App It takes three parameters:

  • •
    element_id ( string ), a mandatory parameter — id The element that will be the widget container. Our default constructor uses a value "vk_app_" + {app_id} .
  • •
    app_id ( integer ), the mandatory parameter is the application identifier.
  • •
    option ( object ) — block options with widget. It may contain fields:
    • •
      mode ( integer ) is a widget type. Possible values:
      • •
        1 - card (cover, title, genre, number of participants and "Play" button), by default;
      • •
        2 — participants (additional avatars of the user’s friend participants are shown, if any);
      • •
        3 Button (button only). For community applications (with URL format app123456_-654321 Only this mode is available).
    • •
      height ( integer The height of the button (for mode = 3 ).

Example

HTML
<script type="text/javascript" src="//vk.ru/js/api/openapi.js?149"></script> <span class="wk_comment"> VK Widget </span> <div id="vk_app_5327745"></div> <script type="text/javascript"> VK.Widgets.App('vk_app_5327745', 5327745, {"mode":3}); </script>

Widget code

To add a widget to your site, simply copy the code to paste to the page you want to place the widget on.

Page URL
Appearance
Code for embedding widget on website
HTML
<!-- Put this script tag to the <head> of your page --> <script type="text/javascript" src="https://vk.ru/js/api/openapi.js?168"></script> <!-- Put this div tag to the place, where the App block will be --> <div id="vk_groups"></div> <script type="text/javascript"> VK.Widgets.App("vk_app_51404928", "51404928", {}); </script>