Method signature

This method allows you to offer a user to add a moment from the game with a link to it:

To create a moment, you must upload an image in an application’s album (details - here).

FAPI.invokeUIMethod("postMoment", momentData);
FAPI.invokeUIMethod("postMoment", JSON.stringify({
    mediaId: '1076356526080',
    blocks: [{
        href: 'https://ok.ru/game/quiz',
        text: 'link text', type: 10,style: 'LIGHT'
    }]
}));
FAPI.invokeUIMethod("postMoment", JSON.stringify({
mediaId: '1076356526080'
}));

Method parameters

NameRequiredTypeDescription
mediaIdYesNumberID of the image that belongs to the application
hrefYesHrefAddress of the link added to the moments
textYesStringText - description of the attached link

Callback example

As a result of this method, the user will be suggested add a moment to their personal page.

Callback when moment was created

method:”postMoment”

result:”ok”

data:”{"id":991157182481”} // moment ID

Callback when user declined to create a moment

method:”postMoment”

result:”error”

data:”cancelled by user”

method:”postMoment”

result:”error”

data:”found link block with invalid href”

method:”postMoment”

result:”error”

data:”found link block with empty href”

Callback when image ID was incorrect

method:”postMoment”

result:”error”

data:”mediaId does not match the application”

Callback when text was empty

method:”postMoment”

result:”error”

data:”found link block with empty text”

Callback when limit was reached

method:”postMoment”

result:”error”

data:”Limit reached. Next available at: 1727951737419”

Callback when an error occurred

method:”postMoment” result:”error” data:”api.communication-error”