-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbatch.php
More file actions
104 lines (82 loc) · 3.47 KB
/
Copy pathbatch.php
File metadata and controls
104 lines (82 loc) · 3.47 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<?php
$pageTitle = 'Bitrix24 Batch Builder — BI Data Tools';
$pageDescription = 'Генератор batch-запросов для API Bitrix24 с автоматической генерацией curl-команд.';
include('header.php'); ?>
<h1><i class="fas fa-layer-group"></i> Bitrix24 Batch Builder</h1>
<div class="tool-container batch-builder">
<div class="tool-section">
<p>Создание batch-запросов для API Bitrix24 с автоматической генерацией curl команд.</p>
<div class="form-group">
<label for="domain">Домен Bitrix24:</label>
<input id="domain" class="form-control" placeholder="mycompany.bitrix24.ru">
</div>
<div class="form-group">
<label for="userId">ID пользователя:</label>
<input id="userId" class="form-control" placeholder="1">
</div>
<div class="form-group">
<label for="webhookKey">Ключ вебхука:</label>
<input id="webhookKey" class="form-control" placeholder="abc1234567890">
</div>
<div class="form-group">
<label for="batchData">Batch данные (JSON):</label>
<textarea id="batchData" class="form-control" rows="10" placeholder='{"halt": 0, "cmd": {"deal1": "crm.deal.add?fields[TITLE]=Test Deal", "deal2": "crm.deal.get?id=$result[deal1]"}}'></textarea>
</div>
<div style="margin: 1.5rem 0;">
<button id="generate" class="btn">Сгенерировать curl ▶</button>
<button id="copy" class="btn btn-sm">Скопировать ⧉</button>
</div>
<div id="err" class="error-message"></div>
<div class="output-section">
<h4>Результат:</h4>
<div id="output" class="output-code"></div>
</div>
</div>
</div>
<script>
const $ = id => document.getElementById(id);
function generateCurl() {
$('err').textContent = '';
const domain = $('domain').value.trim();
const userId = $('userId').value.trim();
const webhookKey = $('webhookKey').value.trim();
const batchData = $('batchData').value.trim();
if (!domain || !userId || !webhookKey || !batchData) {
$('err').textContent = 'Заполните все поля';
return;
}
try {
JSON.parse(batchData);
} catch (e) {
$('err').textContent = 'Некорректный JSON в batch данных';
return;
}
const url = `https://${domain}/rest/${userId}/${webhookKey}/batch.json`;
const curl = `curl -X POST '${url}' \\
-H 'Content-Type: application/json' \\
-d '${batchData.replace(/'/g, "'\\''")}' \\
--compressed`;
$('output').textContent = curl;
}
$('generate').onclick = generateCurl;
$('copy').onclick = async () => {
const text = $('output').textContent;
if (!text) return;
await navigator.clipboard.writeText(text);
$('copy').textContent = '✓ Скопировано';
setTimeout(() => $('copy').textContent = 'Скопировать ⧉', 1500);
};
// Example data
$('domain').value = 'mycompany.bitrix24.ru';
$('userId').value = '1';
$('webhookKey').value = 'your_webhook_key';
$('batchData').value = JSON.stringify({
"halt": 0,
"cmd": {
"deal1": "crm.deal.add?fields[TITLE]=New Deal&fields[STAGE_ID]=NEW",
"contact1": "crm.contact.add?fields[NAME]=John&fields[LAST_NAME]=Doe",
"deal_contact": "crm.deal.contact.add?id=$result[deal1]&fields[CONTACT_ID]=$result[contact1]"
}
}, null, 2);
</script>
<?php include('footer.php'); ?>