Like button

Like button will allow visitors on your site to mark favorite materials and share them with friends on Odnoklassniki.

It will help you understand what your audience is more like it, and at the same time attract new visitors to your site.

Like button builder

Link

Appearance

Size
Form

Additional data(?)

Title
Description
Image URL

Result

Grabbers work

When sharing a resource on Odnoklassniki may occur problems with the processing of media content.

Restrictions on sharing images:

  • min size:
    • web: 128x128
    • mobile: 50x50
  • min aspect ratio: 0.5

For untrusted domains grabber does not handle images and video. You should use one of the page layouts protocols:

Grabber requests are sent from:

  • 217.20.144.0/20
  • 5.61.16.0/21

When you embed multiple widgets on a single page you can use the code:

!function (d, id, did, st) {
  var js = d.createElement("script");
  js.src = "https://connect.ok.ru/connect.js";
  js.onload = js.onreadystatechange = function () {
  if (!this.readyState || this.readyState == "loaded" || this.readyState == "complete") {
    if (!this.executed) {
      this.executed = true;
      setTimeout(function () {onOkConnectReady()}, 0);
    }
  }}
  d.documentElement.appendChild(js);
}(document);
function onOkConnectReady() {
  OK.CONNECT.insertGroupWidget("mineGroupWidgetDivId","50582132228315","{width:250,height:335}");
  OK.CONNECT.insertShareWidget("mineShareWidgetDivId","https://apiok.ru","{width:125,height:25,st:'oval',sz:12,ck:1}");
}

You can track event on page with widgets by the following javascript code:

function listenForShare() {
    if (window.addEventListener) {
        window.addEventListener('message', onShare, false);
    } else {
        window.attachEvent('onmessage', onShare);
    }
}

function listenForJoin() {
    if (window.addEventListener) {
        window.addEventListener('message', onJoin, false);
    } else {
        window.attachEvent('onmessage', onJoin);
    }
}

function onShare(e) {
    var args = e.data.split("$");
    if (args[0] == "ok_shared") {
        alert(args[1]);
    }
}

function onJoin(e) {
    var args = e.data.split("$");
    if (args[0] == "ok_join") {
        alert(args[1]);
    }
}

listenForShare();
listenForJoin();