- Модуль: seo
- Путь к файлу: ~/bitrix/modules/seo/lib/analytics/services/accountvkontakte.php
- Класс: BitrixSeoAnalyticsServicesAccountVkontakte
- Вызов: AccountVkontakte::editPostAnalyticParams
protected function editPostAnalyticParams(array $postIDs, array $params)
{
$result = $this->getPosts($postIDs);
if(!$result->isSuccess())
{
return $result;
}
$posts = $result->getData();
foreach($posts as $post)
{
if($post['post_type'] == 'post_ads' && isset($post['attachments']) && is_array($post['attachments']) && count($post['attachments']) == 1)
{
$attachment = reset($post['attachments']);
if($attachment['type'] != 'link' || mb_strpos($attachment['link']['url'], 'vk.com') !== false)
{
continue;
}
$data = [];
if(isset($params['phone']) && !empty($params['phone']) && mb_strpos($attachment['link']['url'], 'tel:') === 0)
{
$data = [
'owner_id' => $post['owner_id'],
'post_id' => $post['id'],
'attachments' => 'tel:'.$params['phone'],
];
}
elseif(isset($params['url_tags']) && !empty($params['url_tags']))
{
$url = new Uri($attachment['link']['url']);
$url->addParams($params['url_tags']);
if($url->getUri() != $attachment['link']['url'])
{
$data = [
'owner_id' => $post['owner_id'],
'post_id' => $post['id'],
'attachments' => $url->getUri(),
];
}
}
if(!empty($data))
{
$response = $this->getRequest()->send([
'method' => 'POST',
'endpoint' => 'wall.editAdsStealth',
'fields' => $data,
]);
if(!$response->isSuccess())
{
$result->addErrors($response->getErrors());
}
}
}
}
return $result;
}