General information
This is a deprecated SDK that is recommended for usage only for native standalone games and external sites
For games and applications launched from OK please consider using multiplatform SDK
Github repository: ok-js-sdk
App examples using SDK: ok-js-sdk/samples
External JavaScript SDK is intended to be used in MOBILE_HTML games distributed on our mobile platforms and in standalone external applications.
With this SDK you can:
- implement client OAuth for external apps;
- invoke REST API methods;
- implement in-game purchases (same as js sdk) for mobile apps distributed on our mobile platforms;
- implement in-game video ads;
- publish topics in user’s feed;
- send invites and user-to-user notifications via invite/suggest widget.
Setting up and configuring SDK
Before setting up External SDK check your application’s settings:
- MOBILE_HTML or External platform should be enabled;
- for MOBILE_HTML apps:
- callback url must be specified for payments to work correctly;
- for External apps:
- client OAuth authorization is enabled;
- redirect_uri field contains an url that will be used for authorization process;
- all required permissions are enabled. It is highly recommended to enable LONG_ACCESS_TOKEN permission for native IOS and Android applications.
To enable External SDK in your project you need to:
copy oksdk.js file from repository to your project;
enable this script on your page, i.e:
Using SDK
SDK initialization
- OKSDK.init - OK SDK initialization.
This method must be invoked once before using any other SDK method (i.e. on app launch).
OK REST API
- OKSDK.REST.call - OK REST API methods call;
- OKSDK.REST.calcSignature - calculate a signature for REST API method call.
In-app payments
- OKSDK.Payment.show - open in-app payment dialog on a new page;
- OKSDK.Payment.showInFrame - open in-app payment dialog in an embedded iframe;
- OKSDK.Payment.closePaymentFrame - close in-app payment opened in an iframe;
- OKSDK.Payment.query - generate URL for processing in-app payment.
In-app video ads
- OKSDK.Ads.init - ads API initialization;
- OKSDK.Ads.prepareMidroll - request a video ad;
- OKSDK.Ads.showMidroll - shown found video ad;
- OKSDK.Ads.destroy - delete ad widget.
Widgets
- OKSDK.Widgets.post - publish a topic to user’s feed via publishing widget;
- OKSDK.Widgets.invite - invite a friend to a game via invite/suggest widget;
- OKSDK.Widgets.suggest - send a notification from game to a friend via invite/suggest widget.
Utility methods
- OKSDK.Util.getRequestParameters - get all URL parameters passed to an app from OK;
- OKSDK.Util.md5 - calculate md5 signature from a string;
- OKSDK.Util.isLaunchedFromOKApp - check if an app was launched in OK Android app.