Skip to content

Commit fb4071f

Browse files
authored
add and change methods
1 parent 7a20c38 commit fb4071f

9 files changed

Lines changed: 114 additions & 17 deletions

File tree

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1+
There are two types of authorization. One, that is intended for apps, and second for apps and web applications.
2+
3+
Current OpenVK's official instance is located at https://api.openvk.org/. Don't try to visit this link, it will redirect you back - this domain is made special for API requests because of Anti-DDOS limitations.
4+
15
## Password authorization
26

37
To get token, you should call the "token" page:
48

5-
`{YOUR DOMAIN}/token?username={YOUR USERNAME}&password={YOUR PASSWORD}&grant_type=password`
9+
`https://{YOUR DOMAIN}/token?username={YOUR USERNAME}&password={YOUR PASSWORD}&grant_type=password`
10+
11+
Replace `{YOUR DOMAIN}`, `{YOUR USERNAME}` and `{YOUR PASSWORD}` to it's proper value.
612

713
You'll get a response like this:
814

@@ -14,30 +20,28 @@ You'll get a response like this:
1420
}
1521
```
1622

17-
If you need to call the function that requires a token, just put the `access_token` into your GET or POST request.
23+
If you need to call the function that requires a token, just put the `access_token` into your GET or POST request, or in HTTP header "Authorization" as Bearer token.
1824

19-
If you have two-factor authorization turned on, add a `code` field to your POST request and fill it with, you guessed it, authorization code.
25+
If you have two-factor authorization turned on, either sumbit the code via `request_uri` in Web or pass the 2FA code to the `code` field.
2026

21-
**Client name**
27+
### Client name
2228

23-
At this moment, OpenVK API apps are not implemented. But you can set client name for your token: for this, pass `client_name` param at token page:
24-
25-
`{YOUR DOMAIN}/token?username={YOUR USERNAME}&password={YOUR PASSWORD}&grant_type=password&client_name={YOUR CLIENT NAME}`
26-
27-
This name will be seen in some parts of site (online mark and post).
29+
At this moment, OpenVK API apps are not implemented. But you can set client name for your token: for this, pass `client_name` param at token endpoint. This name will be seen in some parts of site (online mark and post).
2830

2931
## OAuth
3032

3133
To get token via OAuth, you should call the "authorize" page:
3234

33-
`{YOUR DOMAIN}/authorize?client_name={YOUR CLIENT NAME}&redirect_uri=&display=page&response_type=token&revoke={0|1}`
35+
`https://{YOUR DOMAIN}/authorize?client_name={YOUR CLIENT NAME}&redirect_uri={REDIRECT URI}&display=page&response_type=token&revoke={0|1}`
36+
37+
You can set any URL at `redirect_uri`. For apps, we recommend setting this to "https://{YOUR DOMAIN}/blank.html".
3438

35-
You can set any URL at `redirect_uri`, but we will set "https://oauth.vk.com/blank.html".
39+
For passing access_token as HTTP GET parameters, set `response_type` to `php`.
3640

3741
On `revoke`=1 old token will be revoked.
3842

3943
Additional params: `prefers_postMessage`, `accepts_stale`.
4044

4145
## Token revoking
4246

43-
As api apps are not implemented, you cannot revoke individual token, but you can revoke all tokens at once: for this, go to {YOUR DOMAIN}/settings?act=security -> "End all sessions".
47+
As api apps are not implemented, you cannot revoke individual token, but you can revoke all tokens at once: for this, go to /settings?act=security -> "End all sessions".
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
### `audio.getAlbums` 🔰
2+
3+
Fields: **`owner_id`**, **`playlist_id`**
4+
5+
Returns playlist.
6+
7+
**Result**:
8+
9+
|Name|Value|Description|
10+
|--|--|--|
11+
|`id`|int|Absolute playlist ID|
12+
|`owner_id`|int|Owner's ID|
13+
|`raw_id`|string|Prettyfied ID|
14+
|`title`|string|Playlist's name|
15+
|`cover_url`|string|URL to covers|
16+
|`last_updated`|string|Date when playlist was updated|
17+
|`explicit`, `followed`, `official`, `listens`|int|Dummies, always 0|
18+
|`size`|int|Count of tracks in playlist|
19+
|`covers` and `list`|array|Dummy, currently empty|
20+
|`description` and `raw_description`|array|Playlist description|
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
### `audio.getPlaylists` 🔰
2+
3+
Alias of [audio.getAlbums](getAlbums.md).
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
### `execute` 🔰
2+
3+
Execute method. Javascript-like scripting language, where you can make up to 25 API calls to generate complex results in one go. Server will compile your code and execute it.
4+
5+
Scripting language support this features:
6+
7+
* Arithmetic operations: `+` `-` `*` `/` `%`
8+
* Variables: `var a`
9+
* Conditions: `if`, `else`
10+
* Loops: `while`, `for`, `break`, `continue`
11+
* Object and array literals: `{key: "value", 'another_key': 123}`, `['a', 123, {}, someVariable]`
12+
* API calls: `API.method({parameters})`
13+
* Object array field selection operator `@.`.
14+
* Functions: `parseInt` and `parseDouble`
15+
* Methods on arrays: `push`, `pop`, `slice`, `splice`, `shift`, `unshift`, `indexOf`
16+
* Methods on strings: `substr`, `split`, `indexOf`
17+
* The `.length` property on strings and arrays
18+
* The special `Args` object that contains any extra parameters you passed to this method
19+
* The `delete` operator to remove fields from objects, e.g. `delete groups[i].description;`
20+
* `//` and `/* ... */` comments
21+
22+
### Code examples
23+
24+
Get posts and notes count for user:
25+
26+
```
27+
var p=API.wall.get({owner_id:1});
28+
var n=API.notes.get({user_id:1});
29+
return [p.count,n.count];
30+
```
31+
32+
Get likes and comments counts from photo:
33+
34+
```
35+
var p=API.photos.getById({"photos":"1_136","extended":1});
36+
return {"pid":p@.id,"likes":p@.likes,"comments":p@.comments,"can_comment":p@.can_comment,"tags":p@.tags};
37+
```
38+
39+
Check if user can post on wall:
40+
41+
```
42+
return API.wall.getById({"posts":"1_164"})[0].comments.can_post;
43+
```
44+
45+
### References
46+
47+
* https://web.archive.org/web/20150429005235/http://vk.com/dev/execute
48+
* https://smithereen.software/docs/api/methods/execute
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
### `newsfeed.getRecommended` 🔰
2+
3+
Alias of [newsfeed.getGlobal](getGlobal.md).
4+
5+
Official clients can access global feed by just simply switching newsfeed type to Recommendations.

docs/openvk_engine/api/methods/photos/get.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@
33
Fields: **`owner_id`**, **`album_id`**, `photo_ids`, `extended`, `photo_sizes`, `offset`, `count`
44

55
Returns a list of photos inside the album.
6+
7+
For default avatar's album, set `album_id` to `profile`.
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
### `polls.addVote` 🔰
22

3-
Fields: **`poll_id`**, **`answers_ids`**
3+
Fields: **`poll_id`**, **`answer_ids`** or **`answer_id`**
44

55
Adds a vote to poll.
6+
7+
`answer_ids` is separated by comma.

docs/openvk_engine/api/objects/audio.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
| keys | Array | Keys for manifest. |
1414
| genre_id | int | Genre id of the track. |
1515
| genre_str | string | String with genre name. |
16-
| lyrics | int | You can get actual lyrics by `audio.getLyrics`. |
16+
| lyrics_id | int | Return current audio if if Lyrics exists. You can get actual lyrics by `audio.getLyrics`. |
1717
| added | bool | Does the user's collection contain this audio?? |
1818
| editable | bool | Can audio be edited by current user? |
1919
| searchable | bool | Is it possible to find audio in search? |

docs/openvk_engine/api/objects/user.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,35 @@
1414
|`status`|string|Status. If user have audiostatus, returns `status_audio`|
1515
|`screen_name`|string|Users shortcode|
1616
|`friend_status`|int|-|
17-
|`last_seen`|int|User last online|
17+
|`online`|int|Is user online. Also adds `mobile_online` if user is online from mobile|
18+
|`last_seen`|object|Object with `platform` (check below) and `time` with user's last time activity|
1819
|`music`|string|Users favourite music|
1920
|`movies`|string|Users favourite films|
2021
|`tv`|string|Users favourite tv shows|
2122
|`books`|string|Users favourite books|
22-
|`city`|string|Users city|
23+
|`city`|object|Object with `id` (always zero) and `city`, which, well, contains user's city|
2324
|`interests`|string|Users interests|
2425
|`quotes`|string|Users favourite quotes|
2526
|`email`|string|Users contact email|
2627
|`telegram`|string|Users telegram|
2728
|`about`|string|Users description|
2829
|`rating`|string|Users rating|
29-
|`correct_counters`|array|Array with user's counters|
30+
|`counters` or `correct_counters`|array|Array with user's counters|
3031
|`background`|array|Background photo urls|
3132
|`reg_date`|int|User registration date|
3233
|`is_dead`|bool|Is user dead|
3334
|`nickname`|string|Nickname, or "middle name"|
3435
|`blacklisted_by_me`|bool|Is blacklisted by current user|
3536
|`blacklisted`|bool|Is this user blacklisted me|
37+
38+
## Platforms
39+
40+
| Id | Name | Description |
41+
|---|---|---|
42+
|1 |`mobile` | Mobile app |
43+
|2 |`iphone` | App for iPhone|
44+
|3 |`ipad` | App for iPad __Currently not used__|
45+
|4 |`android`| App for Android|
46+
|5 |`wphone`| App for Windows Phone. __Currently not used__|
47+
|6 |`windows`| App for Windows 8. __Currently not used__|
48+
|7 |`web` |Website or unknown app|

0 commit comments

Comments
 (0)