-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd_text.php
106 lines (93 loc) · 2.52 KB
/
add_text.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
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
105
<?php
include "cUrls.php";
function test()
{
$kek3 = $_GET['name'];
$val = $_GET['type'];
$data = [
'add' => [
0 => [
'name' => $kek3,
'type' => '1',
'element_type' => $val,
'origin' => 'qwer',
],
],
];
Send_amo('fields',$data);
}
function accaunt(){
global $Response;
var_dump('test');
Send_amo('account?with=custom_fields');
$test = $Response['_embedded']['custom_fields']['contacts'];
global $first_names;
$first_names = array_column($test, 'id','name');
}
function add_elements()
{
$val = $_GET['type'];
if ($val == 1) {
$element = 'contacts';
} elseif ($val == 2) {
$element = 'leads';
} elseif ($val == 3) {
$element = 'companies';
} elseif ($val == 12) {
$element = 'costumers';
} else
echo "Введите коректную сущность";
global $first_names;
$id_element = $_GET['element_id'];
$name = $_GET['name'];
$value = $_GET['value'];
if(array_key_exists($name,$first_names) == FALSE){
test();
accaunt();
$data = [
'update' => [
0 => [
'id' => $id_element,
'updated_at' => time(),
'custom_fields' => [
0 => [
'id' => $first_names[$name],
'values' => [
0 => [
'value' => $value,
],
],
],
],
],
],
];
Send_amo($element, $data);
}
else if(array_key_exists($name,$first_names) == TRUE) {
$data = [
'update' => [
0 => [
'id' => $id_element,
'updated_at' => time(),
'custom_fields' => [
0 => [
'id' => $first_names[$name],
'values' => [
0 => [
'value' => $value,
],
],
],
],
],
],
];
Send_amo($element, $data);
}
};
if(isset($_GET['tik'])){
accaunt();
add_elements();
}
header("Location:text.php");