131 $typeList = static::getTypes();
133 $providers = array();
134 foreach ($typeList as $type)
136 if ($types && !in_array($type, $types))
141 if (in_array($type, [static::TYPE_FACEBOOK, static::TYPE_INSTAGRAM]) && self::isRegionRussian(
true))
146 $authAdapter = static::getInstance()->getAuthAdapter($type);
147 $account = static::getInstance()->getAccount($type);
149 $providers[$type] = array(
151 'HAS_AUTH' => $authAdapter->hasAuth(),
152 'AUTH_URL' => $authAdapter->getAuthUrl(),
153 'HAS_ACCOUNTS' => $account->hasAccounts(),
154 'PROFILE' => $account->getProfileCached(),
155 'ENGINE_CODE' => static::getEngineCode($type),
156 'CLIENTS' => static::getClientsProfiles($authAdapter)
160 if ($providers[$type][
'HAS_AUTH'] && empty($providers[$type][
'PROFILE']))
162 static::removeAuth($type);
163 $providers[$type][
'HAS_AUTH'] =
false;
178 if (!static::canUse())
185 $account = static::getAccount($type);
186 $accountsResult = $account->getList();
187 if ($accountsResult->isSuccess())
189 while ($accountData = $accountsResult->fetch())
191 $accountData = $account->normalizeListRow($accountData);
192 if ($accountData[
'ID'])
195 'id' => $accountData[
'ID'],
196 'name' => $accountData[
'NAME'] ? $accountData[
'NAME'] : $accountData[
'ID']
203 self::$errors = $accountsResult->getErrorMessages();
276 $type = $authAdapter->getType();
277 return array_values(array_filter(array_map(
function ($item) use ($type) {
278 $service =
new static();
279 $service->setClientId($item[
'proxy_client_id']);
281 $authAdapter = Retargeting\AuthAdapter::create($type)->setService($service);
283 $account = Account::create($type)->setService($service);
284 $account->getRequest()->setAuthAdapter($authAdapter);
286 $profile = $account->getProfileCached();
294 $authAdapter->removeAuth();
297 }, $authAdapter->getAuthorizedClientsList())));