AMO CRM лид передать в определенную колонку воронки?
Передаю лиды с сайта в АМО CHV/ Но лид падает в колонку НЕРАЗОБРАННОЕ. А необходимо в определенную колонку кидать сразу. Код прикладываю.
<?php require_once 'access.php'; $domain = 'mysite.ru'; $pipeline_id = 6902970; // ID воронки $statusID = 58714286; // ID колонки воронки $user_amo = 8325454; // ID сотрудника ответственного за сделку $data = [ [ "name" => $formname, "responsible_user_id" => (int) $user_amo, 'status_id' => (int) $statusID, 'pipeline_id' => (int) $pipeline_id, "_embedded" => [ "metadata" => [ "category" => "forms", "form_id" => 1, "form_name" => "Форма на сайте", "form_page" => $target, "form_sent_at" => strtotime(date("Y-m-d H:i:s")), "ip" => $ip, "referer" => $domain ], "contacts" => [ [ "first_name" => $name, "custom_fields_values" => [ [ "field_code" => "EMAIL", "values" => [ [ "enum_code" => "WORK", "value" => $email ] ] ], [ "field_code" => "PHONE", "values" => [ [ "enum_code" => "WORK", "value" => $phone ] ] ], ] ] ], ], ] ]; $method = "/api/v4/leads/complex"; $headers = [ 'Content-Type: application/json', 'Authorization: Bearer ' . $access_token, ]; $curl = curl_init(); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_USERAGENT, 'amoCRM-API-client/1.0'); curl_setopt($curl, CURLOPT_URL, "https://$subdomain.amocrm.ru".$method); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST'); curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data)); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); curl_setopt($curl, CURLOPT_HEADER, false); curl_setopt($curl, CURLOPT_COOKIEFILE, 'amo/cookie.txt'); curl_setopt($curl, CURLOPT_COOKIEJAR, 'amo/cookie.txt'); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0); $out = curl_exec($curl); $code = curl_getinfo($curl, CURLINFO_HTTP_CODE); $code = (int) $code; $errors = [ 301 => 'Moved permanently.', 400 => 'Wrong structure of the array of transmitted data, or invalid identifiers of custom fields.', 401 => 'Not Authorized. There is no account information on the server. You need to make a request to another server on the transmitted IP.', 403 => 'The account is blocked, for repeatedly exceeding the number of requests per second.', 404 => 'Not found.', 500 => 'Internal server error.', 502 => 'Bad gateway.', 503 => 'Service unavailable.' ]; if ($code < 200 || $code > 204) die( "Error $code. " . (isset($errors[$code]) ? $errors[$code] : 'Undefined error') ); $Response = json_decode($out, true); $Response = $Response['_embedded']['items']; $output = 'ID добавленных элементов списков:' . PHP_EOL; foreach ($Response as $v) if (is_array($v)) $output .= $v['id'] . PHP_EOL; return $output; |
<?php require_once 'access.php'; $domain = 'mysite.ru'; $pipeline_id = 6902970; // ID воронки $statusID = 58714286; // ID колонки воронки $user_amo = 8325454; // ID сотрудника ответственного за сделку $data = [ [ "name" => $formname, "responsible_user_id" => (int) $user_amo, 'status_id' => (int) $statusID, 'pipeline_id' => (int) $pipeline_id, "_embedded" => [ "metadata" => [ "category" => "forms", "form_id" => 1, "form_name" => "Форма на сайте", "form_page" => $target, "form_sent_at" => strtotime(date("Y-m-d H:i:s")), "ip" => $ip, "referer" => $domain ], "contacts" => [ [ "first_name" => $name, "custom_fields_values" => [ [ "field_code" => "EMAIL", "values" => [ [ "enum_code" => "WORK", "value" => $email ] ] ], [ "field_code" => "PHONE", "values" => [ [ "enum_code" => "WORK", "value" => $phone ] ] ], ] ] ], ], ] ]; $method = "/api/v4/leads/complex"; $headers = [ 'Content-Type: application/json', 'Authorization: Bearer ' . $access_token, ]; $curl = curl_init(); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_USERAGENT, 'amoCRM-API-client/1.0'); curl_setopt($curl, CURLOPT_URL, "https://$subdomain.amocrm.ru".$method); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST'); curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data)); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); curl_setopt($curl, CURLOPT_HEADER, false); curl_setopt($curl, CURLOPT_COOKIEFILE, 'amo/cookie.txt'); curl_setopt($curl, CURLOPT_COOKIEJAR, 'amo/cookie.txt'); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0); $out = curl_exec($curl); $code = curl_getinfo($curl, CURLINFO_HTTP_CODE); $code = (int) $code; $errors = [ 301 => 'Moved permanently.', 400 => 'Wrong structure of the array of transmitted data, or invalid identifiers of custom fields.', 401 => 'Not Authorized. There is no account information on the server. You need to make a request to another server on the transmitted IP.', 403 => 'The account is blocked, for repeatedly exceeding the number of requests per second.', 404 => 'Not found.', 500 => 'Internal server error.', 502 => 'Bad gateway.', 503 => 'Service unavailable.' ]; if ($code < 200 || $code > 204) die( "Error $code. " . (isset($errors[$code]) ? $errors[$code] : 'Undefined error') ); $Response = json_decode($out, true); $Response = $Response['_embedded']['items']; $output = 'ID добавленных элементов списков:' . PHP_EOL; foreach ($Response as $v) if (is_array($v)) $output .= $v['id'] . PHP_EOL; return $output;
Дополнительно:
Ответы:
Короче сам спросил - сам сделал. Надо убрать из кода metadata
Опишите проблему, и специалист поможет с настройкой, исправлением ошибки или доработкой сайта. Подберём понятный план работ без лишней переписки.
Пока нет других ответов. Будьте первым, кто поможет автору.
Ответить на вопрос
Для передачи лидов в определенную колонку воронки в AMO CRM, вам необходимо использовать API этой CRM системы. Вот пример кода на PHP, который поможет вам сделать это:
[ "id" => $column_id ] ]; $curl = curl_init($url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_HTTPHEADER, [ "Authorization: Bearer {$api_token}", "Content-Type: application/json" ]); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data)); $response = curl_exec($curl); curl_close($curl); $result = json_decode($response, true); if (isset($result['status']) && $result['status'] === "success") { echo "Лид успешно перемещен в колонку воронки!"; } else { echo "Произошла ошибка при перемещении лида в колонку воронки."; } ?>
В этом коде мы отправляем POST запрос на API AMO CRM с данными о перемещении лида в определенную колонку воронки. Поменяйте переменные $lead_id, $column_id и $api_token на ваши реальные значения. После выполнения запроса, вы получите ответ от API, который позволит вам узнать успешно ли было перемещение лида или произошла ошибка.