Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/qucals/VK-API

C++ Library for working with VK API
https://github.com/qucals/VK-API

api callback-api cmake cpp cxx longpoll streaming-api vk vk-api vk-bot vkapi vkontakte vkontakte-api

Last synced: about 2 months ago
JSON representation

C++ Library for working with VK API

Awesome Lists containing this project

README

        



VK API Library

[![Status](https://img.shields.io/badge/status-active-success.svg)]()
[![CodeFactor](https://www.codefactor.io/repository/github/qucals/VK-API/badge/master)](https://www.codefactor.io/repository/github/qucals/VK-API/overview/master)


[![Workflow](https://github.com/qucals/VK-API/actions/workflows/macos.yml/badge.svg)]()
[![Workflow](https://github.com/qucals/VK-API/actions/workflows/ubuntu.yml/badge.svg)]()
[![Workflow](https://github.com/qucals/VK-API/actions/workflows/windows.yml/badge.svg)]()


[![GitHub Issues](https://img.shields.io/github/issues/qucals/VK-API.svg)](https://github.com/qucals/VK-API/issues)
[![GitHub Pull Requests](https://img.shields.io/github/issues-pr/qucals/VK-API.svg)](https://github.com/qucals/VK-API/pulls)
[![License](https://img.shields.io/github/license/qucals/VK-API)](/LICENSE)

---

The easiest C++ library to use for working with the VK API.


## 📝 Table of Contents

- [About](#about)
- [Getting Started](#getting_started)
- [Deployment](#deployment)
- [Usage](#usage)
- [Built Using](#built_using)
- [Authors](#authors)

## 🧐 About

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.

## 🏁 Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See [deployment](#deployment) for notes on how to deploy the project on a live system.

Steps :
1. Copy this repository to your computer;
2. Open terminal in a directory where you copied the repository;
3. Change a main directory: `cd build`;
4. Enter the following command with your replacements: `cmake ..`;
5. Build the project by the next command: `cmake --build .`.

### Prerequisites

The library using 2 additional dependencies:
1. [curlpp](https://www.curlpp.org/) - A library for working with requests;
2. [json](https://github.com/nlohmann/json) - A library for working with json.

Note that you also can install it by `vcpkg` on Windows.

### Installing

For connection this library to yours you need to follow the next steps:
1. Copy this repository to your computer;
2. Open terminal in a directory where you copied the repository;
3. Change a main directory: `cd build`;
4. Enter the following command with your replacements: `cmake ..`;
5. Build and install the project by the next command: `cmake --build . --target install --config Release`;
6. If building and install is ended successfully you can see there are `include` and `lib`'s directories in `install`'s directory.

After the above steps you will have a static library and include's files that you can connection to your project.

## 🎈 Usage

There are two base examples.

Authorization for Bot:

```CXX
#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:

```CXX
#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.

## 🚀 Deployment

### CMake

If you use CMake you make use the `find_package` instruction.
After [installing](#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:
```CMake
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`;

### Others

If you use another building system you need to connection include's files and lib file which is located `bin\include` and `lib` directories.

## ⛏️ Built Using

- [CMake](https://cmake.org/) - Cross-platform family of tools designed to build

## ✍️ Authors

- [@qucals](https://github.com/qucals) - Idea & Initial work