Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
accountvkads.php
1<?
2
4
8use \Bitrix\Seo\Retargeting\Account;
11
12class AccountVkads extends Account
13{
14 const TYPE_CODE = 'vkads';
15
16 protected static $listRowMap = array(
17 'ID' => 'ACCOUNT_ID',
18 'NAME' => 'NAME',
19 );
20
21 public function getList()
22 {
23 $response = $this->getRequest()->send(array(
24 'methodName' => 'retargeting.account.list',
25 'parameters' => array()
26 ));
27 $data = $response->getData();
28 $data = array_values(array_filter($data, function ($item) {
29 return ($item['account_type'] == 'general'); // only "general" is supported
30 }));
31 $response->setData($data);
32 return $response;
33 }
34
35 public function getProfile()
36 {
37 $response = $this->getRequest()->send(array(
38 'methodName' => 'analytics.profile',
39 'parameters' => []
40 ));
41
42 if (
43 $response->isSuccess()
44 && ($data = $response->fetch())
45 )
46 {
47 $result = [
48 'ID' => $data['ID'],
49 'NAME' => $data['FIRST_NAME'] . ' ' . $data['LAST_NAME'],
50 'LINK' => 'https://ads.vk.com/hq/budget/transactions/',
51 ];
52
53 $result['PICTURE'] = (Context::getCurrent()->getRequest()->isHttps() ? 'https' : 'http')
54 . '://'
55 . Context::getCurrent()->getServer()->getHttpHost() . '/bitrix/images/seo/integration/vklogo.svg';
56
57 return $result;
58 }
59
60 return null;
61 }
62}
static getCurrent()
Definition context.php:241