The translation was generated automatically and may contain mistakes
Publication of references
By placing a button under the articles of your publication or blog Publish the VKontakte , you’ll let 100 million users VKontakte quickly share links to your content with their friends.
Every time a user VKontakte clicks on this button on your site, a note with a link to your site is automatically created on their VKontakte page. After that, the user’s friends will immediately be able to find out about the article from the page News and from the personal page of the published user.
The link to your site will forever remain available to all visitors of the page that published it. Thus, your site will be able to attract the attention of additional visitors not only in a short period after the appearance of the news. This feature favorably distinguishes the publication of VKontakte from other methods of publication on the Internet.
Putting a VKontakte button on your website is easy. To do this, we suggest using the button builder below.
Connecting Widget
To add a button to your website Publish the VKontakte , follow the following steps:
Step 1. In the tag <head> On your website, add a link.. share.js :
<script type="text/javascript" src="https://vk.ru/js/api/share.js?93" charset="windows-1251"></script>Step 2. On the page of your site, you need to add a button code to any convenient place. The simplest way to do this is:
<script type="text/javascript">
document.write(VK.Share.button());
</script>This code adds a standard-looking button — with rounded corners and a link counter — that will prompt you to post a link to the page where the code was inserted on the wall.
For dynamic websites
If the content, including the link posting buttons VKontakte is updated dynamically on your site, then you can use the text returned by the function VK.Share.button to create publishing buttons “on the fly?2?. All you have to do is allocate a container for the button in the right place, and after loading the content, execute a code like the following:
document.getElementById('vk_share_button').innerHTML = VK.Share.button('http://mysite.com', {type: 'link'});Websites without JavaScript support
If you can’t run JavaScript scripts on your site (for example, your blog platform doesn’t support this functionality), you can post a direct link to publish the VKontakte The reference is as follows:
The code to place it might look like this:
<a href="https://vk.ru/share.php?url=http://mysite.com" target="_blank">Поделиться ?1?’Контакте</a>Additional settings
Method VK.Share.button It takes two parameters:
- •
share_options(object(b) Parameters of publication. An object that can contain fields:- •
url(string) —URLthe page to which the link is to be published. Note that Cyrillic addresses need to be passed to Punycode. - •
title(stringThe title of the publication. If the parameter is not specified, the title will be taken from the publication page automatically. - •
image(string) —URLImages for publication. If the parameter is not specified, the image will be taken from the publication page automatically. - •
noparse(boolean) — if a value is passed in this parametertrue, the VKontakte server will not make an additional request to download the missing information from the published page. If the valuefalse, the request will always be sent. - •
no_vk_links(integer, [0,1] — if a value is passed in this parameter1, there will be no active links to the user profile in the publication window (available only on mobile devices).
- •
- •
button_options(object) — button options. An object that can contain fields:- •
type(stringType of button. Possible values:- •
rounda button with rounded corners and a counter (by default); - •
round_nocounta button with rounded corners without a counter; - •
button- button with right angles and with a counter; - •
button_nocounta button with right angles without a reference counter; - •
link— text link with the VKontakte icon; - •
link_noicon— text link without an icon; - •
custom- its own button code, specified in the parametertext.
- •
- •
text(stringfor all types of buttons exceptcustom, parametertextsets the text on the button, for the typecustomThis parameter defines the HTML code of the button.
- •
Information used
If the parameter noparse is not transmitted or equal to false then in the preview dialog of the notes before publication, the information from the published page will be used. The VKontakte server loads the content of the published page and searches for the necessary parameters:
- •The headline. If there are tags on the published page
og:title,mrc__share_titleortwitter:titlethe title will be taken from one of them (specified first), otherwise the tag will be used<title>. - •Illustration. If there are tags on the published page
og:image,twitter:image,imagethen the image address for the illustration will be taken from the first one, otherwise the first 8 tags will be taken<img src="...">, and of these, illustrations are provided that are larger than 130 pixels in width and height. If the picture is more than 537 pixels wide, then the link on the site will be accompanied by an enlarged picture.
An example of a site code indicating the title, description, and illustration data used to publish the VKontakte>
<head>
<meta property="og:title" content="Заголовок страницы" />
<meta property="og:image" content="https://pp.vk.me/c629531/v629531034/3172e/xEBYyER1WE4.jpg" />
</head>Important! Data for publication can be cached. If you have changed the data on your site, and VKontakte old values are displayed when you publish, reset the cache to link to the page pages.clearCache .
Examples of Use
Example code to post a link to a page other than the current one:
<script type="text/javascript">
document.write(VK.Share.button('http://mysite.com'));
</script>An example code that defines all the parameters of a publication without having to refer to the page for them:
<script type="text/javascript">
document.write(VK.Share.button({
url: 'http://mysite.com',
title: 'Заголовок страницы',
image: 'http://mysite.com/mypic.jpg',
noparse: true
}));
</script>An example of code that creates a button without specifying the publication parameters, but displayed as a link Publish With the VKontakte icon:
document.write(VK.Share.button(false, {type: 'link', text: 'Опубликовать'}));An example of the code creating a button, with a given link and a publication title, in the form of an icon VKontakte 32x32pp:
document.write(VK.Share.button({url: 'http://mysite.com', title: 'Заголовок страницы'}, {type: 'custom', text: '<img src="http://vk.ru/images/vk32.png" />'}));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.
Selecting a button
You can choose the type of button to publish the article VKontakte depending on the design of your site. The button can have straight or rounded corners, contain or not contain a counter with the number of publications sent. you can arrange the button in the form of a regular text link or a small VKontakte icon..