WebTolk Joomla Extensions
90 Extensions
11 Categories
401 Versions released
397248 Downloads
The method allows you to add leads from Joomla to an amoCRM account in batches.
POST /api/v4/leads
Official documentation of the method
The method allows you to get the data of a specific transaction by ID.
The method is available according to the user's rights.
Batch methods of the amoCRM REST API allow you to add no more than 50 elements at a time. In the context of this method - no more than 50 leads.
Name | Type | Description |
---|---|---|
$data |
array | amoCRM transaction data array according to official documentation of the method. |
The return value corresponds to the amoCRM documentation for this method.
stdClass Object
(
[_links] => stdClass Object
(
[self] => stdClass Object
(
[href] => https://yoursubdomain.amocrm.ru/api/v4/leads
)
)
[_embedded] => stdClass Object
(
[leads] => Array
(
[0] => stdClass Object
(
[id] => 20534409
[request_id] => 0
[_links] => stdClass Object
(
[self] => stdClass Object
(
[href] => https://yoursubdomain.amocrm.ru/api/v4/leads/20534409
)
)
)
)
)
)
The official documentation says about a possible response code 401 The user is not authorized. The WT Amocrm library returns an error object of the following structure:
stdClass Object
(
[error_code] => 400
[error_message] => createLeads function: Error while trying to create lead in Amo CRM. Amo CRM API response: request_id: 0
code: NotSupportedChoice
path: pipeline_id
detail: The value you selected is not a valid choice.
title: Bad Request
type: https://httpstatus.es/400
status: 400
detail: Request validation failed
)
use Webtolk\Amocrm\Amocrm;
$amocrm = new Amocrm();
$leads = [];
$order_summ = 15453.44; // The amount, the budget of the transaction.
$lead_data = [
'created_by' => 0, // The ID of the user creating the lead. When the value 0 is passed, the lead will be considered created by the robot. The field is optional
'name' => 'Order #2987427', // displayed lead name
'pipeline_id' => 3753682, // pipline id. The list of pipelines is obtained by the method getLeadsPiplines()
'price' => (int) $order_summ, // amoCRM accepts only integer values here. If you need amounts up to a penny, we pass them additionally to the fields or a note.
];
$lead_data['_embedded']['contacts'] = array();
/**
* The contact data array is added as a nested entity.
*/
$contact_id = 32942695; // Contact id. We search and get it via the method getContacts.
$contact = [
'id' => $contact_id,
'is_main' => true,
];
$lead_data['_embedded']['contacts'][] = $contact;
$leads[] = $lead_data;
$result_amo_crm = $amocrm->createLeads($leads);