Instructions for VK API
Table of Contents
Introduction
All this is a ready-made solution for the VK api. I am providing you with a file, already with ready-made functions for all operations, so far there is only one, this is class.php
.
Connect the file to your project, and then just call all the necessary functions. An example of the initial page is shown in index.php
There are a lot of methods in the VK api, so I have divided the readme into categories, with each addition of a new method, I will add to the description of functions.
First, get your token! Go to the description.
Users
Methods for working with user data.
users.get
Returns extended user information.
For this method, I have two functions:
- The first one returns only the token.
getUserToken
- The second returns only the id.
getUserId
In both functions, it is necessary to pass the first parameter to the user's login, often this is a phone number, and the second parameter is the user's password. ($login, $password)
users.getFollowers
Returns a list of user IDs that are subscribers of the user.
There are also two functions for this request.
- The first one is necessary to get a lot of subscribers with their ID.
getFollowersItems
- The second is to get the number of subscribers currently.
getFollowersCount
To work, you need to pass the token parameter. ($token)
users.getSubscriptions
Returns a list of user IDs and public pages that are included in the list of user subscriptions.
There are also two functions for this request.
- The first one is necessary to get a lot of subscriptions with their ID.
getSubscriptionsItems
- The second is to get the number of subscriptions currently.
getSubscriptionsCount
To work, you need to pass the token parameter. ($token)
Friends
Methods for working with friends.
friends.get
Returns a list of the user's friend IDs or extended information about the user's friends (when using the fields parameter).
There are also two functions for this request.
- The first one is necessary to get an array of friends with their id.
getFriendsItems
- The second is to get the number of users currently
getFriendsCount
To work, you need to pass the token parameter. ($token)
friends.delete
Removes a user from the friends list or rejects a friend request.
The function for deleting friends accepts an array with the user id and a token. deleteFriends($id_friend = [], $token)
If an error occurred (invalid id, error in the process,...), an error will appear, otherwise it will output true.