Method signature
To enable this widget your application requires to have an approve. To get an approve please send a message to api-support@ok.ru email
This SDK is deprecated
For games and applications launched from OK please consider using multiplatform SDK
Publish a topic to user’s feed via publishing widget.
Where:
- returnUrl - URL on which user will be redirected after a post was confirmed / declined. Optional parameter;
- options - additional widget parameters, object:
- attachment - topic content;
- silent - automatically close widget window on confirm / decline. Is ignored if returnUrl parameter is specified;
- utext - allow user to add a comment to a topic;
- nohead - show OK header in a widget window.
Full parameters description and topic blocks list can be found here - publishing widget.
Return URL message
If returnUrl parameter was specified and options.silent was not user will be redirected to a specified URL.
Method’s result will be passed in an URL as additional GET parameters:
- result - method’s result, object:
- type - result status:
- success - topic was successfully created;
- error - an error occurred or publishing was declined by a user.
- code - error code. More information about error codes and their meanings can be found here
- message - error message;
- id - published topic id. If you application is not approved topic id is going to be 0 and topic won’t be published;
- signature - request signature.
- type - result status:
If topic was successfully created result will be
?result={"type":"success","id":"123456789123456","signature":"5c1a50d97a870c2****9d68cda15756"}
If user cancelled publishing
?result={"type":"error","code":12,"message":"Operation was cancelled by user"}
If an error occurred
?result={"type":"error","code":104,"message":"Bad signature "}
Window postMessage
If returnUrl was not specified an options.silent was then postMessage with method’s result will be sent to a parent window.
Message will contain data field with all the valuable data about method’s result. This data is same as in case of returnUrl specified.
If topic was successfully created result will be
If user cancelled publishing
If an error occurred
You can add an eventListener which will process such messages:
Example usage
With returnUrl specified
Example with a postMessage
Method call results in a widget being opened in a new window with a topic preview. User can either decline or confirm topic publishing: