Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
accountvkontakte.php
1<?
2
4
8use \Bitrix\Seo\Retargeting\Account;
11
13{
14 const TYPE_CODE = 'vkontakte';
15
16 protected static $listRowMap = array(
17 'ID' => 'ACCOUNT_ID',
18 'NAME' => 'NAME',
19 );
20
21 public function getList()
22 {
23 $result = $this->getRequest()->send([
24 'methodName' => 'retargeting.account.list',
25 ]);
26
27 if ($result->isSuccess())
28 {
29 $list = [];
30 while ($item = $result->fetch())
31 {
32 if (
33 (
34 isset($item['CLIENT_NAME'])
35 || isset($item['NAME'])
36 )
37 && isset($item['ID'])
38 )
39 {
40 $list[] = [
41 'NAME' => !empty(trim($item['CLIENT_NAME'])) ? $item['CLIENT_NAME'] : $item['NAME'],
42 'ACCOUNT_ID' => $item['ID'],
43 ];
44 }
45 }
46 $result->setData($list);
47 }
48
49 return $result;
50 }
51
52 public function getProfile()
53 {
54 $response = $this->getRequest()->send(array(
55 'methodName' => 'retargeting.profile',
56 'parameters' => array()
57 ));
58
59 if ($response->isSuccess())
60 {
61 $data = $response->fetch();
62 return array(
63 'ID' => $data['ID'],
64 'NAME' => $data['FIRST_NAME'] . ' ' . $data['LAST_NAME'],
65 'LINK' => 'https://vk.com/' . $data['SCREEN_NAME'],
66 'PICTURE' => (Context::getCurrent()->getRequest()->isHttps() ? 'https' : 'http')
67 . '://'
68 . Context::getCurrent()->getServer()->getHttpHost() . '/bitrix/images/seo/integration/vklogo.svg',
69 );
70 }
71
72 return null;
73 }
74}
static getCurrent()
Definition context.php:241