ok.ru

1.2.0 • Public • Published

Ok.ru API with node

This npm module allows you to simplify making API requests into odnoklassniki REST API.

Example usage

ok = require("ok.ru")
 
# Basic configuration params 
requestOptions = {
  applicationSecretKey: '{secretKey}',
  applicationKey: '{applicationKey}',
  applicationId: '{applicationId}',
}
 
ok.setOptions(requestOptions)
# You can specify accessToken in requestOptions or separately 
# For example: if you have many users and you whant to iterate through them 
ok.setAccessToken('{access_token}')
 
# All data passed in Object 
ok.post { method: 'group.getUserGroupsV2' }(err, data) ->
  # Some actions with data 
 
# You can also specify types of requests 
ok.postok.get
 
# Or pass in, as argument 
new ok.api 'get'{ method: 'users.isAppUser' }(err, data) ->
  # some actions with data 
 
# It properly handle errors 
ok.setAccessToken('invalid_token') # Invalid token 
 
new ok.api 'get'{ method: 'users.isAppUser' }(err, data, response) ->
  # some actions with data 
  alert "Alarm! Error! #{err}" if err?
  # It can transport all response and headers 
  console.log response

Refresh user token method

ok.refresh '{refresh_token}'(err, data) ->
  data.access_token # new token 

Test it!

Add your params at test/settings.yml and you are ready to go!
$ mocha

Enjoy!

TODO

  • What do you need? Let me know or fork.

Package Sidebar

Install

npm i ok.ru

Weekly Downloads

70

Version

1.2.0

License

none

Last publish

Collaborators

  • cre-o