JavaScript SDK

JavaScript SDK is SDK of built-in applications that are iframes, the content of which is located on the developer’s server.

SDK contains 4 method groups:

Connecting a library:

<script type="text/javascript" src="//api.ok.ru/js/fapi5.js" defer="defer"></script>

When using js + flash in a flash application, the “wmode=opaque” parameter must be set.

After every transition inside an iframe it is necessary to perform an initialization again with the FAPI.init method, as well as pass the following parameters:

  • api_server
  • apiconnection
  • web_server
  • application_key
  • session_key
  • session_secret_key

API_callback

Methods from the FAPI.UI group don’t require the callback function to be passed. After the method is executed, a global function will be called, and the developer must realize it. The function must have the signature:

function API_callback(method, result, data);

Here:

  • method - the name of the method called
  • result - the result of the execution (“ok” if successful, “cancel” if the user canceled the action)
  • data - additional information, for example, for showInvite() – a list of IDs of invited friends, separated by commas, in the string format.