3namespace Bitrix\Seo\Marketing;
6use Bitrix\Main\Localization\Loc;
27 return Loader::includeModule(
'seo') && Loader::includeModule(
'socialservices');
37 self::$isQueueUsed =
true;
68 self::$errors[] = Loc::getMessage(
"SEO_RETARGETING_EMPTY_AUDIENCE_NAME");
71 $audience->setAccountId($accountId);
75 $addResult = $audience->add($parameters);
76 if ($addResult->isSuccess() && $addResult->getId())
78 return $addResult->getId();
82 self::$errors = $addResult->getErrorMessages();
94 $audience->setAccountId($accountId);
95 $addResult = $audience->createLookalike($sourceAudienceId,
$options);
96 if ($addResult->isSuccess() && $addResult->getId())
98 return $addResult->getId();
102 self::$errors = $addResult->getErrorMessages();
120 $audience->setAccountId($accountId);
121 $audiencesResult = $audience->getList();
122 if ($audiencesResult->isSuccess())
124 while ($audienceData = $audiencesResult->fetch())
126 $audienceData = $audience->normalizeListRow($audienceData);
127 if ($audienceData[
'ID'])
130 'id' => $audienceData[
'ID'],
131 'isSupportMultiTypeContacts' => $audience->isSupportMultiTypeContacts(),
133 'supportedContactTypes' => $audienceData[
'SUPPORTED_CONTACT_TYPES'],
135 $audienceData[
'NAME']
137 $audienceData[
'NAME'] . (
138 $audienceData[
'COUNT_VALID'] > 0 ?
139 ' (' . $audienceData[
'COUNT_VALID'] .
')'
151 self::$errors = $audiencesResult->getErrorMessages();
165 return $account->getRegionsList();
176 $providers = static::getServiceProviders($types);
180 $providers[
$type][
'URL_AUDIENCE_LIST'] = $audience->getUrlAudienceList();
181 $providers[
$type][
'IS_SUPPORT_ACCOUNT'] = $audience->isSupportAccount();
182 $providers[
$type][
'IS_SUPPORT_REMOVE_CONTACTS'] = $audience->isSupportRemoveContacts();
184 $providers[
$type][
'IS_SUPPORT_MULTI_TYPE_CONTACTS'] = $audience->isSupportMultiTypeContacts();
185 $providers[
$type][
'IS_SUPPORT_ADD_AUDIENCE'] = $audience->isSupportAddAudience();
186 $lookalikeAudienceParams = $audience->getLookalikeAudiencesParams();
187 $providers[
$type][
'IS_SUPPORT_LOOKALIKE_AUDIENCE'] = !!$lookalikeAudienceParams;
188 $providers[
$type][
'LOOKALIKE_AUDIENCE_PARAMS'] = $lookalikeAudienceParams;
202 static $audiences =
array();
203 if (!isset($audiences[
$config->type]))
211 $audiences[
$config->type] = $audience;
215 $audience = $audiences[
$config->type];
218 $audience->setAccountId(
$config->accountId);
219 static::$isQueueUsed ? $audience->enableQueueMode() : $audience->disableQueueMode();
220 if (
$config->autoRemoveDayNumber)
222 $audience->enableQueueAutoRemove(
$config->autoRemoveDayNumber);
226 $audience->disableQueueAutoRemove();
229 $audienceImportResult = $audience->addContacts(
233 'type' =>
$config->contactType,
234 'parentId' =>
$config->parentId
238 self::$errors = $audienceImportResult->getErrorMessages();
239 return $audienceImportResult->isSuccess();
249 return self::$errors;
259 self::$errors =
array();
269 return count(self::$errors) > 0;
280 static::getService()->getAuthAdapter(
$type)->removeAuth();
290 if (!static::canUse())
295 return static::getService()->getTypes();
306 $typeList = static::getServiceTypes();
308 $providers =
array();
309 foreach ($typeList as
$type)
311 if ($types && !in_array(
$type, $types))
319 $canUserMultiClients = $authAdapter->canUseMultipleClients();
323 'HAS_AUTH' => $authAdapter->hasAuth(),
324 'AUTH_URL' => $authAdapter->getAuthUrl(),
325 'PROFILE' => $authAdapter->getToken() ? $account->getProfileCached() :
false,
327 if ($canUserMultiClients)
329 $providers[
$type][
'CLIENTS'] = static::getClientsProfiles($authAdapter);
330 if (empty($providers[
$type][
'CLIENTS']))
332 $providers[
$type][
'HAS_AUTH'] =
false;
337 if ($providers[
$type][
'HAS_AUTH'] && empty($providers[
$type][
'PROFILE']))
339 static::removeAuth(
$type);
340 if (!$canUserMultiClients)
342 $providers[
$type][
'HAS_AUTH'] =
false;
358 return array_values(array_filter(array_map(
function ($item) use (
$type) {
360 $service->setClientId($item[
'proxy_client_id']);
367 $account->getRequest()->setAuthAdapter($authAdapter);
369 $profile = $account->getProfileCached();
390 if (!static::canUse())
397 $account = static::getService()->getAccount(
$type);
398 $accountsResult = $account->getList();
399 if ($accountsResult->isSuccess())
401 while ($accountData = $accountsResult->fetch())
403 $accountData = $account->normalizeListRow($accountData);
404 if ($accountData[
'ID'])
407 'id' => $accountData[
'ID'],
408 'name' => $accountData[
'NAME'] ? $accountData[
'NAME'] : $accountData[
'ID']
415 self::$errors = $accountsResult->getErrorMessages();
if(!Loader::includeModule('messageservice')) $provider
static getClientsProfiles(AuthAdapter $authAdapter)
static addLookalikeAudience($type, $accountId=null, $sourceAudienceId=null, $options=[])
static getAudiences($type, $accountId=null)
static getProviders(array $types=null)
static getAccounts($type)
static addToAudience(AdsAudienceConfig $config, $contacts)
static getServiceProviders(array $types=null)
static addAudience($type, $accountId=null, $name=null)
static getAudience($type)
static getAuthAdapter($type)
setService(IService $service)
getAuthorizedClientsList()
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"