6use \Bitrix\Seo\Retargeting\Audience;
7use \Bitrix\Seo\Retargeting\Response;
25 'COUNT_VALID' =>
'AUDIENCE_COUNT',
26 'COUNT_MATCHED' =>
'AUDIENCE_COUNT',
27 'SUPPORTED_CONTACT_TYPES' => [
40 public function add(array $data)
43 'methodName' =>
'retargeting.audience.add',
45 'name' => $data[
'NAME'],
47 'email' =>
'example@example.com',
52 $responseData = $response->getData();
53 if (isset($responseData[
'id']))
55 $response->setId($responseData[
'id']);
64 foreach (static::$listRowMap[
'SUPPORTED_CONTACT_TYPES'] as $contactType)
66 if (!isset($contacts[$contactType]))
70 foreach ($contacts[$contactType] as $contact)
72 $data[] = [$contactType => $contact];
82 'methodName' =>
'retargeting.audience.contacts.add',
98 'methodName' =>
'retargeting.audience.list',
99 'parameters' => array(
100 'accountId' => $this->accountId
104 if ($result->isSuccess())
107 $data = $result->getData();
109 if (is_array($data[
'items']))
111 $list = array_values(array_filter($data[
'items'],
function ($item) {
115 $result->setData($list);
175 $clientId = $this->service->getClientId();
176 $clientId = preg_replace(
'/[^a-zA-Z0-9_-]/',
'', (
string)$clientId);
177 $accountId = preg_replace(
'/[^a-zA-Z0-9_-]/',
'', (
string)$this->accountId);
178 $audienceRequestId = preg_replace(
'/[^a-zA-Z0-9_-]/',
'', (
string)$audienceRequestId);
179 $audienceSize = (int)$audienceSize;
181 return __CLASS__ .
'::processLookalikeAudienceAgent("'.$clientId.
'", "'.
$accountId.
'", "' . $audienceRequestId .
'", "'.$audienceSize.
'");';
192 $result = $audience->getRequest()->send(array(
193 'methodName' =>
'retargeting.audience.lookalike.request.get',
194 'parameters' => array(
196 'requestId' => $audienceRequestId,
199 if (!$result->isSuccess())
204 $data = $result->getData();
205 $audienceRequest = array_filter($data[
'items'],
206 function ($item) use ($audienceRequestId)
208 return $audienceRequestId == $item[
'id'];
212 if (empty($audienceRequest))
217 $audienceRequest = array_shift($audienceRequest);
219 if ($audienceRequest[
'status'] ==
'search_in_progress')
221 return $audience->getLookalikeAudienceAgentName($audienceRequestId, $audienceSize);
223 if ($audienceRequest[
'status'] ==
'search_done')
225 $audience->getRequest()->send(array(
226 'methodName' =>
'retargeting.audience.lookalike.add',
227 'parameters' => array(
229 'requestId' => $audienceRequestId,
230 'level' => $audienceSize
const ENUM_CONTACT_TYPE_PHONE
const ENUM_CONTACT_TYPE_EMAIL
const ENUM_CONTACT_TYPE_INTERNAL_ID
const ENUM_CONTACT_TYPE_IDFA_GAID
removeContacts($audienceId, array $contacts, array $options)
static processLookalikeAudienceAgent($clientId, $accountId, $audienceRequestId, $audienceSize)
getLookalikeAudienceAgentName($audienceRequestId, $audienceSize)
const USER_LIST_TYPE_HUMAN
addLookalikeAudienceAgent($audienceRequestId, $audienceSize)
prepareContacts(array $contacts=[])
static isSupportAddAudience()
importContacts($audienceId, array $contacts, array $options)
static isSupportRemoveContacts()
const MIN_CONTACTS_FOR_ACTIVATING
const MAX_CONTACTS_PER_PACKET
getLookalikeAudiencesParams()
static isSupportCreateLookalikeFromSegments()