• Модуль: seo
  • Путь к файлу: ~/bitrix/modules/seo/lib/analytics/services/accountvkontakte.php
  • Класс: BitrixSeoAnalyticsServicesAccountVkontakte
  • Вызов: AccountVkontakte::editGroupAnalyticParams
protected function editGroupAnalyticParams(array $groupIDs, array $params)
{
	$result = $this->getGroups(array_values($groupIDs));
	if(!$result->isSuccess())
	{
		return $result;
	}
	$groups = $result->getData();
	foreach($groups as $group)
	{
		$data = [];
		if(isset($params['url_tags']) && !empty($params['url_tags']) && isset($group['site']))
		{
			$uri = new Uri($group['site']);
			$uri->addParams($params['url_tags']);
			$data['website'] = $uri->getUri();
		}
		if(isset($params['phone']) && !empty($params['phone']) && $group['phone'] != $params['phone'])
		{
			$data['phone'] = $params['phone'];
		}
		if(!empty($data))
		{
			$data['id'] = $group['id'];
			$response = $this->getRequest()->send([
				'method' => 'POST',
				'endpoint' => 'groups.edit',
				'fields' => $data,
			]);
			if(!$response->isSuccess())
			{
				$result->addErrors($response->getErrors());
			}
		}

		if(isset($params['url_tags']) && !empty($params['url_tags']) && isset($group['links']) && is_array($group['links']) && !empty($group['links']))
		{
			foreach($group['links'] as $link)
			{
				$url = new Uri($link['url']);
				$url->addParams($params['url_tags']);
				if($url->getUri() != $link['url'])
				{
					$response = $this->getRequest()->send([
						'method' => 'POST',
						'emdpoint' => 'groups.deleteLink',
						'fields' => [
							'group_id' => $group['id'],
							'link_id' => $link['id'],
						]
					]);
					if($response->isSuccess())
					{
						$response = $this->getRequest()->send([
							'method' => 'POST',
							'endpoint' => 'groups.addLink',
							'fields' => [
								'group_id' => $group['id'],
								'text' => $link['desc'],
								'link' => $url->getUri(),
							]
						]);
					}
					if(!$response->isSuccess())
					{
						$result->addErrors($response->getErrors());
					}
				}
			}
		}

		// todo add here edit call_to_action button
	}

	return $result;
}