-
Notifications
You must be signed in to change notification settings - Fork 0
/
monday-add-guests.php
54 lines (42 loc) · 1.61 KB
/
monday-add-guests.php
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
require __DIR__ . '/func/get_csrf.php';
require __DIR__ . '/func/add_monday_user.php';
require __DIR__ . '/func/find_monday_user.php';
$config = 'config.local.php';
if (! file_exists(__DIR__ . '/' . $config))
{
fwrite(STDERR, "Can't find `$config` file!\n");
exit(1);
}
$config = require $config;
$company = $config['company'];
$boardId = $config['board_id'];
$rootDomain = "$company.monday.com";
$baseUrl = "https://$rootDomain";
$boardUrl = "$baseUrl/boards/$boardId";
$subscribeUrl = "$baseUrl/projects/$boardId/subscribers";
$searchUrl = "$baseUrl/search/add_subscribers_search";
$cookie = 'Cookie: ' . $config['cookie'];
$opts = [
'http' => [
'header' => $cookie,
],
];
$csrf = get_csrf($boardUrl, $opts);
$opts['http']['method'] = 'POST';
$userAgent = 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.183 Safari/537.36 Vivaldi/1.96.1147.36';
$opts['http']['header'] .= "\r\nAccept: application/json, text/javascript, */*; q=0.01\r\nContent-Type: application/json; charset=UTF-8";
$opts['http']['header'] .= "\r\nX-Csrf-Token: $csrf\r\nReferer: $boardUrl\r\nOrigin: $baseUrl\r\nAuthority: $rootDomain";
$opts['http']['header'] .= "\r\nAccept-Language: en-US,en;q=0.9\r\nX-Requested-With: XMLHttpRequest\r\nUser-Agent: $userAgent";
$file = 'userlist';
if (! file_exists($file))
{
fwrite(STDERR, "Can't find `$file` file!\n");
exit(1);
}
$users = file($file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
foreach ($users as $user)
{
$findResult = find_monday_user($user, $searchUrl, $boardId, $opts);
add_monday_user($findResult, $subscribeUrl, $opts);
}