-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
63 lines (53 loc) · 1.73 KB
/
index.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
<?php
//создает POST запрос на создание нераборанного
require 'exception.php';
require 'read_csv.php';
$token = json_decode(file_get_contents('save_token_key.json'), true);
$access_token = $token['access_token'];
$way = '/api/v4/leads/unsorted/forms';
$link = 'https://bordo.amocrm.ru' . $way;
$headers = [
'Content-Type:application/json',
'Authorization: Bearer ' . $access_token,
];
$file = 'Book2.csv';
$csvArray = ReadCsv($file);
foreach($csvArray as $key => $array) {
$data[] = [
'source_name' => 'text',
'source_uid' => 'a1fee7c0fc436088e64ba2e8822ba2b3',
'pipeline_id' => 3717283,
'_embedded' => [
'leads' => [[
'name' => $array['lead'],
]],
'contacts' => [[
'name' => $array['contact'],
"custom_fields_values" => [[
"field_id" => 446081,
"values" => [[
"value" => $array['phone'],
]]
]]
]]
],
'metadata' => [
'ip' => '123.222.2.22',
'form_id' => 'test',
'form_sent_at' => time(),
'form_name' => 'Тестовая форма',
'form_page' => 'https://example.com',
'referer' => 'https://example.com'
],
];
}
$curl = curl_init();
curl_setopt($curl,CURLOPT_URL, $link);
curl_setopt($curl,CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl,CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($curl,CURLOPT_POSTFIELDS, json_encode($data));
$out = curl_exec($curl);
$code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
ExeptionCode($code);
echo "Успешно создано $key";