Bot API changes
Attention! This is a second version of Bot API. It should mostly work the as the previous version but some things may and do differ:
- base API address has changed. Previously it was https://botapi.ok.ru, now it is https://api.ok.ru/graph;
- access_token format has changed. If you already use a previously generated token it is highly recommended to renew it;
- error response format has changed. New format follow traditional OK API error response format. More info about errors;
- object IDs and object IDs format have changed. You need to update them after migrating to new Bot API version;
- access token lifetime is restricted to 30 days but is renewed every time an API method is invoked using this token. It now works as a LONG_ACCESS_TOKEN.
Group messaging is a service for instant messages between OK group and it’s members developed on a base of Graph API.
Group messages are currently available for all our users on mobile and desktop version of OK. It is planned to add this feature in our native Android and iOS applications in nearest future.
Group moderators can communicate with group members on a desktop version of OK or by using Bot API.
Acquiring an access token
Specific access token must be acquired in order to use Bot API.
Для работы с Bot API от имени группы необходимо получить специальный ключ доступа.
Access token is a special string that is used when invoking API methods on group’s behalf. It should be passed in a access_token parameter when working with API.
Group administrator can get this token on settings page of a group.
Follow this step to get your access token:
Open a «Settings» page of a group
Open a «Management» section
Press a key «Generate access key» and the bottom of the page
Confirm your choice
Get a token and use it while working with API
Bot API is based on Graph API
With Bot API you can do the following things:
- get information about all chats via method graph.user.chats;
- get information about a specific chat via method graph.user.chat;
- get specific chat’s messages via method GET graph.user.messages;
- send new messages to group chats via method POST graph.user.messages;
- subscribe to all new chat events via method graph.user.subscribe;
- unsubscribe from all new chat events via method graph.user.unsubscribe;
- view a list of current new events subscriptions via method graph.user.subscriptions.