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:

https://connect.ok.ru/dk
   ?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.

ParameterRequiredDescription
st.appYesApplication id
st.attachmentYesJson with mediatopic information. This parameter can be base64-encoded
st.signatureYesQuery signature
st.returnNoOn this URL user will be redirected with publication result. If is empty - result of the publication will be sent via HTML5 postMessage
st.popupNoPerform automatic centering and fit the windows size.
Possible values: on/off (default)
st.silentNoClose window after publishing. Ignored if st.return is specified.
Possible values: on/off (default)
st.utextNoAllow user to add custom comment.
Possible values: on/off (default)
st.noheadNoDo not display Odnoklassniki header.
Possible values: on/off (default)
st.access_tokenNoIn case of OAuth authorization - valid access_token
st.groupIdNoIf 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:

https://connect.ok.ru/dk
   ?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:

md5("st.attachment=" + attachment + "st.return=" + return_url + secretKey);

If st.return is empty:

md5("st.attachment=" + attachment + secretKey);

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:

{"id":"67601133491473"}

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:

{"type":"success","id":"67601141224721","signature":"94fef0ec7d967e1eb41d5a505d1668ca"}

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:

md5("id=" + id + secretKey);