Publishing widget
For external sites and native mobile applications Odnoklassniki provide a specific mechanism for publishing in the user notes or into a group’s feed (only if a user has permission to post to a specific group).
To use this widget application must be approved. Send approve request to api-support@ok.ru.
Publishing a user note
For publishing you should open browser window (or iframe) with a specially crafted URL:
?st.cmd=WidgetMediatopicPost
&st.app={application_id}
&st.attachment={attachment_json}
&st.signature={signature}
&st.return={return_url}
&st.popup={popup}
&st.silent={silent}
&st.utext={text}
&st.nohead={nohead}
The values of all URL arguments must be encoded.
Parameter | Required | Description |
---|---|---|
st.app | Yes | Application id |
st.attachment | Yes | Json with mediatopic information. This parameter can be base64-encoded |
st.signature | Yes | Query signature |
st.return | No | On this URL user will be redirected with publication result. If is empty - result of the publication will be sent via HTML5 postMessage |
st.popup | No | Perform automatic centering and fit the windows size. Possible values: on/off (default) |
st.silent | No | Close window after publishing. Ignored if st.return is specified. Possible values: on/off (default) |
st.utext | No | Allow user to add custom comment. Possible values: on/off (default) |
st.nohead | No | Do not display Odnoklassniki header. Possible values: on/off (default) |
st.access_token | No | In case of OAuth authorization - valid access_token |
st.groupId | No | If you intend to publish a topic to group, group id ,ust be passed with this paramater |
Publishing topic to a group
Group topic publishing works just as user note publishing. You need to open a browser window (or iframe) with a specific URL:
?st.cmd=WidgetMediatopicPost
&st.app={application_id}
&st.groupId={group_id}
&st.attachment={attachment_json}
&st.signature={signature}
&st.return={return_url}
&st.popup={popup}
&st.silent={silent}
&st.utext={text}
&st.nohead={nohead}
All parameters are the same, but st.groupId parameter is required to be passed if you need to publish a post to a group.
Also it is required for user to have a permission to publish posts into a group (i.e. he needs to be a group moderator or user created posts should be enabled in this group’s settings).
Query signature st.signature
If st.access_token is not empty secretKey is session_secret_key, in the other case secretKey is an application secret key.
Values must not be encoded.
If st.return isn’t empty:
If st.return is empty:
Result
Topic creation result depends on whether parameter st.return was or was not specified.
If topic was created without using of st.return parameter, the answer would be the following:
If 0 is return instead of a topic id, it means that your application needs to be approved. To get an approve for your application please send an email to api-support@ok.ru
When st.return is specified and topic is successfully created, you will get the following result:
Result parameters are:
- type - flag identifying if a topic was created successfully or the process ended with an error. Possible values: success, error;
- id - created topic id;
- signature - signature to validate the response on your side;
- code - error code that was invoked during topic creation process, only present in response if type=error;
- message - additional error information, only present in response if type=error.
Signature parameter can be calculated by this formula: