getAccountInfo method
The getAccountInfo method of the WT amoCRM library for Joomla returns information about the amoCRM account. In Joomla, extensions are needed, rather, to indicate normal communication with amoCRM.
REST API endpoint
GET /api/v4/account
Official documentation of the method
Description
The method allows you to get the necessary information about the account, for example: ID, name, directory of task types, user groups and other parameters.
Restrictions
The method is available to all users of the account.
Differences
The documentation of the amoCRM method informs about a possible optional parameter $string
. At the moment, the WT Amocrm library does not support it.
Return values
HTTP 200 Successful response
The return value corresponds to the amoCRM documentation for this method.
Sample response
stdClass Object
(
[id] => 29145784564
[name] => yoursubdomian
[subdomain] => yoursubdomian
[created_at] => 1673927032
[created_by] => 0
[updated_at] => 1673927032
[updated_by] => 0
[current_user_id] => 6520033
[country] => RU
[currency] => RUB
[currency_symbol] => ₽
[customers_mode] => disabled
[is_unsorted_on] => 1
[mobile_feature_version] => 0
[is_loss_reason_enabled] => 1
[is_helpbot_enabled] =>
[is_technical_account] => 1
[contact_name_display_order] => 1
[_links] => stdClass Object
(
[self] => stdClass Object
(
[href] => https://yoursubdomian.amocrm.ru/api/v4/account
)
)
)
HTTP 40x Failed response
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 (example for the code 404):
stdClass Object
(
[error_code] => 404
[error_message] => getAccountInfo function: Error while trying to get Account info from Amo CRM. Amo CRM API response: title: Not Found
type: https://httpstatus.es/404
status: 404
detail: Cannot GET https://yoursubdomain.amocrm.ru/account1!
)
Code example
$amocrm = new Amocrm();
$result_amo_crm = $amocrm->getAccountInfo();
if(isset($result_amo_crm->error_code) && !empty($result_amo_crm->error_code)){
return '<div class="alert alert-danger row">
<div class="col-2 h1">'.$result_amo_crm->error_code.'</div>
<div class="col-10">'.$result_amo_crm->error_message.'</div>
</div>';
}
if(count((array)$result_amo_crm) > 0){
$current_user_id = $result_amo_crm->current_user_id;
}