echo $query['map'];
GET https://<subdomain>.amocrm.ru/ajax/contacts/list/?json=1&page=1&filter[cf][266363][]=test@test.test&useFilter=y&element_type=1
$link = 'https://' . $subdomain . '.amocrm.ru/api/v3/leads?limit=1000&filter[123456]=&fields=1234567,sale,654321';
$link = 'https://' . $subdomain . '.amocrm.ru/api/v3/leads?limit=10000&filter[504091]=&filter[123456]=';
$update_leads = [];
foreach ($leads as $lead) {
$update_leads[] = [
'id' => $lead['id'],
'updated_at' => time(),
'custom_fields' => [
[
'id' => 504091,
'values' => [
[
'value' => <FIELDS VALUE>
]
]
],
[
'id' => 123456,
'values' => [
[
'value' => 'TEST'
]
]
]
]
];
}
$link = 'https://' . $subdomain . '.amocrm.ru/api/v2/leads';
$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_USERAGENT, 'amoCRM-API-client/1.0');
curl_setopt($curl, CURLOPT_URL, $link);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode(['update' => $update_leads]));
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_COOKIEFILE, __DIR__ . '/cookie.txt');
curl_setopt($curl, CURLOPT_COOKIEJAR, __DIR__ . '/cookie.txt');
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
$out = json_decode(curl_exec($curl), 1);
curl_close($curl);
<?php
$user = array(
'USER_LOGIN' => '<USER LOGIN>',
'USER_HASH' => '<USER HASH>'
);
$subdomain = '<SUBDOMAIN>';
$link = 'https://' . $subdomain . '.amocrm.ru/private/api/auth.php?type=json';
$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_USERAGENT, 'amoCRM-API-client/1.0');
curl_setopt($curl, CURLOPT_URL, $link);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($user));
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_COOKIEFILE, __DIR__ . '/cookie.txt');
curl_setopt($curl, CURLOPT_COOKIEJAR, __DIR__ . '/cookie.txt');
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
$out = json_decode(curl_exec($curl), 1);
curl_close($curl);
$leads = [];
$link = 'https://' . $subdomain . '.amocrm.ru/api/v3/leads?limit=1000&filter[<FIELDS ID>]=';
do {
$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_USERAGENT, 'amoCRM-API-client/1.0');
curl_setopt($curl, CURLOPT_URL, $link);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_COOKIEFILE, __DIR__ . '/cookie.txt');
curl_setopt($curl, CURLOPT_COOKIEJAR, __DIR__ . '/cookie.txt');
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
$out = json_decode(curl_exec($curl), 1);
curl_close($curl); #Завершаем сеанс cURL
$leads = array_merge($out['_embedded']['leads']);
$link = $out['_links']['next']['href'];
} while (isset($out['_links']['next']));
$update_leads = [];
foreach ($leads as $lead) {
$update_leads[] = [
'id' => $lead['id'],
'updated_at' => time(),
'custom_fields' => [
[
'id' => <FIELDS ID>,
'values' => [
[
'value' => <FIELDS VALUE>
]
]
]
]
];
}
echo '<pre>';
var_dump($update_leads);
echo '</pre>';
<?php
$user = array(
'USER_LOGIN' => '<USER LOGIN>',
'USER_HASH' => '<USER HASH>'
);
$subdomain = '<SUBDOMAIN>';
$link = 'https://' . $subdomain . '.amocrm.ru/private/api/auth.php?type=json';
$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_USERAGENT, 'amoCRM-API-client/1.0');
curl_setopt($curl, CURLOPT_URL, $link);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($user));
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_COOKIEFILE, __DIR__ . '/cookie.txt');
curl_setopt($curl, CURLOPT_COOKIEJAR, __DIR__ . '/cookie.txt');
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
$out = json_decode(curl_exec($curl), 1);
curl_close($curl);
$leads = [];
$link = 'https://' . $subdomain . '.amocrm.ru/api/v3/leads?limit=1000&filter[<FIELDS ID>]=';
do {
$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_USERAGENT, 'amoCRM-API-client/1.0');
curl_setopt($curl, CURLOPT_URL, $link);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_COOKIEFILE, __DIR__ . '/cookie.txt');
curl_setopt($curl, CURLOPT_COOKIEJAR, __DIR__ . '/cookie.txt');
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
$out = json_decode(curl_exec($curl), 1);
curl_close($curl); #Завершаем сеанс cURL
$leads = array_merge($out['_embedded']['leads']);
$link = $out['_links']['next']['href'];
} while (isset($out['_links']['next']));
$update_leads = [];
foreach ($leads as $lead) {
$update_leads[] = [
'id' => $lead['id'],
'updated_at' => time(),
'custom_fields' => [
[
'id' => <FIELDS ID>,
'values' => [
[
'value' => <FIELDS VALUE>
]
]
]
]
];
}
echo '<pre>';
var_dump($update_leads);
echo '</pre>';
foreach ( $field['options'] as $key => $value ) {
echo '<li><label><input
name="' . esc_attr( $field['name'] ) . '"
value="' . esc_attr( $key ) . '"
type="checkbox"
class="' . esc_attr( $field['class'] ) . '"
style="' . esc_attr( $field['style'] ) . '"
' . (array_search($key, is_array($field["value"]) ? $field["value"]:array($field["value"])) !== false ? 'checked="checked"': '' ). ' /> ' . esc_html( $value ) . '</label>
</li>';
}
То есть если у вас limit_offset = 500 то в первой итерации limit_rows = 0, во второй 500, в третьей 1000 и тд