Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
adcampaignfacebook.php
1<?
2
4
6
8{
9 const TYPE_CODE = 'facebook';
10
17 public function createCampaign(array $params = [])
18 {
19 $response = $this->getRequest()->send(array(
20 'methodName' => 'marketing.create.campaign',
21 'parameters' => $params
22 ));
23
24 if ($response->isSuccess())
25 {
26 return $response->getData();
27 }
28
29 $errors = [];
30 foreach ($response->getErrors() as $error)
31 {
32 $errors[] = $error->getMessage();
33 }
34 return [
35 'error' => true,
36 'errors' => $errors
37 ];
38 }
39
40 public function getAdSetList($accountId)
41 {
42 $response = $this->getRequest()->send(array(
43 'methodName' => 'marketing.adset.list',
44 'parameters' => array(
45 'accountId' => $accountId
46 )
47 ));
48
49 if ($response->isSuccess())
50 {
51 $result = [];
52 while($data = $response->fetch())
53 {
54 $result[] = $data;
55 }
56 return $result;
57 }
58
59 return null;
60 }
61
62 public function getCampaignList($accountId)
63 {
64 $response = $this->getRequest()->send(array(
65 'methodName' => 'marketing.campaign.list',
66 'parameters' => array(
67 'accountId' => $accountId
68 )
69 ));
70 if ($response->isSuccess())
71 {
72 $result = [];
73 while($data = $response->fetch())
74 {
75 $result[] = $data;
76 }
77 return $result;
78 }
79
80 return null;
81 }
82
83 public function updateAds($adsId)
84 {
85 $response = $this->getRequest()->send(array(
86 'methodName' => 'marketing.ads.update',
87 'parameters' => array(
88 'adsId' => $adsId
89 )
90 ));
91
92 return $response->isSuccess();
93 }
94
95 public function getAds($adsId)
96 {
97 $response = $this->getRequest()->send(array(
98 'methodName' => 'marketing.ads.get',
99 'parameters' => array(
100 'adsId' => $adsId
101 )
102 ));
103 if ($response->isSuccess())
104 {
105 $result = [];
106 while($data = $response->fetch())
107 {
108 $result[] = $data;
109 }
110 return $result;
111 }
112 }
113
114 public function searchTargetingData($params)
115 {
116 $response = $this->getRequest()->send(array(
117 'methodName' => 'marketing.search.targeting',
118 'parameters' => array(
119 'query' => $params['q'],
120 'type' => $params['type'],
121 'locale' => \Bitrix\Main\Application::getInstance()->getContext()->getLanguage(),
122 )
123 ));
124 if ($response->isSuccess())
125 {
126 return $response->getData();
127 }
128 }
129}