The easiest C++ library to use for working with the VK API.
This is a library for easy work with the VK API. It contains all the standard queries that are defined by VK. This makes it easier to access LongPollServer VK.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
- Copy this repository to your computer;
- Open terminal in a directory where you copied the repository;
- Change a main directory:
cd build
; - Enter the following command with your replacements:
cmake ..
; - Build the project by the next command:
cmake --build .
.
The library using 2 additional dependencies:
Note that you also can install it by vcpkg
on Windows.
For connection this library to yours you need to follow the next steps:
- Copy this repository to your computer;
- Open terminal in a directory where you copied the repository;
- Change a main directory:
cd build
; - Enter the following command with your replacements:
cmake ..
; - Build and install the project by the next command:
cmake --build . --target install --config Release
; - If building and install is ended successfully you can see there are
include
andlib
's directories ininstall
's directory.
After the above steps you will have a static library and include's files that you can connection to your project.
There are two base examples.
Authorization for Bot:
#include "Bot.hpp"
int main(int argc, const char** argv)
{
std::string access_token = "your_token_there";
std::string group_id = "your_group_id_there";
vk::base::bot::Bot bot(group_id);
if (bot.Auth(access_token) == true) {
// The further behaviour
} else {
// The further behaviour
}
return 0;
}
Authorization for User:
#include "User.hpp"
int main(int argc, const char** argv)
{
std::string app_id = "your_app_id_there";
std::string app_secure_key = "your_app_secure_key_there";
std::string login = "your_login_there";
std::string password = "your_password_there";
std::string access_token = "your_access_token_there";
vk::base::user::User user(app_id, app_secure_key);
if(user.Auth(login, password) == true) {
// The further behaviour
} else {
// The further behaviour
}
// or
if (user.Auth(access_token) == true) {
// The further behaviour
} else {
// The further behaviour
}
return 0;
}
There are other examples of using this library in the examples
directory.
If you use CMake you make use the find_package
instruction.
After installing the project you can find vkapiConfig.cmake in the lib/cmake
directory. For connection this library to your project you need to add the following code to your cmake file:
set(CMAKE_CXX_FLAGS " -lcurl")
set(VKAPI_DIR *path_to_vkapiconfig.cmake*)
find_package(VKAPI CONFIG REQUIRED)
target_link_libraries(${PROJECT_NAME} VKAPI::VKAPI)
Replace:
*path_to_vkapiconfig.cmake*
to the path to directory lib/cmake
;
If you use another building system you need to connection include's files and lib file which is located bin\include
and lib
directories.
- CMake - Cross-platform family of tools designed to build
- @qucals - Idea & Initial work