6use \Bitrix\Seo\Retargeting\Audience;
7use \Bitrix\Seo\Retargeting\Response;
20 'COUNT_VALID' =>
'AUDIENCE_COUNT',
21 'COUNT_MATCHED' =>
'AUDIENCE_COUNT',
22 'SUPPORTED_CONTACT_TYPES' => array(
23 self::ENUM_CONTACT_TYPE_EMAIL,
24 self::ENUM_CONTACT_TYPE_PHONE,
25 self::ENUM_CONTACT_TYPE_IDFA_GAID,
26 self::ENUM_CONTACT_TYPE_INTERNAL_ID
35 public function add(array $data)
38 'methodName' =>
'retargeting.audience.add',
39 'parameters' => array(
40 'accountId' => $this->accountId,
41 'name' => $data[
'NAME'],
46 $responseData = $response->getData();
47 if (isset($responseData[
'id']))
49 $response->setId($responseData[
'id']);
58 foreach (static::$listRowMap[
'SUPPORTED_CONTACT_TYPES'] as $contactType)
60 if (!isset($contacts[$contactType]))
65 $data[] = implode(
',', $contacts[$contactType]);
68 return implode(
',', $data);
75 'methodName' =>
'retargeting.audience.contacts.add',
76 'parameters' => array(
77 'accountId' => $this->accountId,
93 'methodName' =>
'retargeting.audience.list',
94 'parameters' => array(
95 'accountId' => $this->accountId
108 for ($i=1; $i<10;$i++)
113 'FIELDS' => [
'AUDIENCE_SIZE'],
121 'methodName' =>
'retargeting.audience.lookalike.request.add',
122 'parameters' => array(
123 'accountId' => $this->accountId,
124 'audienceId' => $sourceAudienceId,
127 if (!$result->isSuccess())
132 $data = $result->getData();
133 if ($data[
'request_id'])
135 $result->setId($data[
'request_id']);
149 $clientId = $this->service->getClientId();
150 $clientId = preg_replace(
'/[^a-zA-Z0-9_-]/',
'', (
string)$clientId);
151 $accountId = preg_replace(
'/[^a-zA-Z0-9_-]/',
'', (
string)$this->accountId);
152 $audienceRequestId = preg_replace(
'/[^a-zA-Z0-9_-]/',
'', (
string)$audienceRequestId);
153 $audienceSize = (int)$audienceSize;
155 return __CLASS__ .
'::processLookalikeAudienceAgent("'.$clientId.
'", "'.
$accountId.
'", "' . $audienceRequestId .
'", "'.$audienceSize.
'");';
166 $result = $audience->getRequest()->send(array(
167 'methodName' =>
'retargeting.audience.lookalike.request.get',
168 'parameters' => array(
170 'requestId' => $audienceRequestId,
173 if (!$result->isSuccess())
178 $data = $result->getData();
179 $audienceRequest = array_filter($data[
'items'],
180 function ($item) use ($audienceRequestId)
182 return $audienceRequestId == $item[
'id'];
186 if (empty($audienceRequest))
191 $audienceRequest = array_shift($audienceRequest);
193 if ($audienceRequest[
'status'] ==
'search_in_progress')
195 return $audience->getLookalikeAudienceAgentName($audienceRequestId, $audienceSize);
197 if ($audienceRequest[
'status'] ==
'search_done')
199 $audience->getRequest()->send(array(
200 'methodName' =>
'retargeting.audience.lookalike.add',
201 'parameters' => array(
203 'requestId' => $audienceRequestId,
204 'level' => $audienceSize
removeContacts($audienceId, array $contacts, array $options)
static processLookalikeAudienceAgent($clientId, $accountId, $audienceRequestId, $audienceSize)
getLookalikeAudienceAgentName($audienceRequestId, $audienceSize)
addLookalikeAudienceAgent($audienceRequestId, $audienceSize)
static isSupportAddAudience()
importContacts($audienceId, array $contacts, array $options)
prepareContacts(array $contacts=array())
static isSupportRemoveContacts()
const MIN_CONTACTS_FOR_ACTIVATING
const MAX_CONTACTS_PER_PACKET
getLookalikeAudiencesParams()
createLookalike($sourceAudienceId, array $options)