Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
responsegoogle.php
1<?
2
4
5use \Bitrix\Main\Error;
7use \Bitrix\Main\Web\Json;
8use \Bitrix\Seo\Retargeting\Response;
9
10
12{
13 const TYPE_CODE = 'google';
14
15 protected function getSkippedErrorCodes()
16 {
17 return array(
18 '400' // invalid_parameter: segment data not modified
19 );
20 }
21
22 public function parse($data)
23 {
24 if (!is_array($data))
25 {
26 $data = array();
27 }
28 if ($data['error'])
29 {
30 if (is_array($data['error']))
31 {
32 if ($data['error']['status'] && $data['error']['status'] == 'UNAUTHENTICATED')
33 {
34 $this->addError(new Error("Unauthorized"));
35 $this->setData([]);
36 return;
37 }
38 $data['error'] = $data['error']['message'];
39 }
40 $errorMessage = $data['error'];
41 if (mb_strpos($errorMessage, 'AuthenticationError.CUSTOMER_NOT_FOUND') !== false
42 || mb_strpos($errorMessage, 'AuthenticationError.NOT_ADS_USER') !== false) // google user hasn't google ads accounts
43 {
44 $this->setData([]);
45 return;
46 }
47 if (mb_strpos($errorMessage, 'UserListError.ADVERTISER_NOT_WHITELISTED_FOR_USING_UPLOADED_DATA') !== false)
48 {
49 $errorMessage = Loc::getMessage('SEO_RETARGETING_SERVICE_RESPONSE_GOOGLE_CANT_ADD_AUDIENCE', ['#LINK#' => 'https://support.google.com/adspolicy/answer/6299717']);
50 }
51 if (mb_strpos($errorMessage, 'UserListError.NAME_ALREADY_USED') !== false)
52 {
53 $errorMessage = Loc::getMessage('SEO_RETARGETING_SERVICE_RESPONSE_GOOGLE_NAME_ALREADY_USED');
54 }
55 $errorMessage = Loc::getMessage('SEO_RETARGETING_SERVICE_RESPONSE_GOOGLE_ERROR', ['#ERROR#' => $errorMessage]);
56 $this->addError(new Error($errorMessage));
57 }
58 $this->setData($data);
59 }
60}
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29