-
Notifications
You must be signed in to change notification settings - Fork 17
/
04-users.cpp
29 lines (22 loc) · 884 Bytes
/
04-users.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include "slacking.hpp"
#include <fstream>
int main() {
// Load the token from a file. You can also specify directly the token in your code as a string.
std::string mytoken;
std::ifstream infile("token.txt");
std::getline(infile, mytoken);
auto& slack = slack::create(mytoken);
// You can display all the JSON response
std::cout << slack.users.list().dump(4) << std::endl;
// You can display filtered informations
auto users = slack.users.list_magic(); // this is a vector so you can iterate on it
std::cout << users << '\n';
// Iterate on your users
for (auto const& user : users) {
std::cout << user.name << std::endl;
}
// Get precise informations on a specific user
auto user_id = users[0].id;
std::cout << user_id << std::endl;
std::cout << slack.users.info(user_id).dump(4) << std::endl;
}