- Модуль: seo
- Путь к файлу: ~/bitrix/modules/seo/lib/leadads/services/formvkontakte.php
- Класс: BitrixSeoLeadAdsServicesFormVkontakte
- Вызов: FormVkontakte::loadLeads
public function loadLeads($formId): Result
{
if (!isset($formId) || !isset($this->accountId))
{
return (new Result())
->addError(new Error('Can not load leads'));
}
$limit = self::LIMIT_DEFAULT;
$response = $this->loadLeadsByForm($formId,
[
'limit' => $limit,
'offset' => 0,
]
);
if (!$response->isSuccess())
{
return (new Result())
->addError(new Error('Can not load leads'));
}
$leads = $response->getData();
if (count($leads) === $limit)
{
$limit = self::LIMIT_MAX;
while (true)
{
$response = $this->loadLeadsByForm($formId, [
'limit' => $limit,
'offset' => count($leads),
]);
if (!$response->isSuccess())
{
break;
}
$leads = array_merge($leads, $response->getData());
if (count($response->getData()) < $limit)
{
break;
}
}
}
return (new Result())->setData($leads);
}