Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
responsegoogle.php
1
<?
2
3
namespace
Bitrix\Seo\Retargeting\Services
;
4
5
use \Bitrix\Main\Error;
6
use
Bitrix\Main\Localization\Loc
;
7
use \Bitrix\Main\Web\Json;
8
use \Bitrix\Seo\Retargeting\Response;
9
10
11
class
ResponseGoogle
extends
Response
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
}
Bitrix\Main\Error
Definition
error.php:14
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Main\Response
Definition
response.php:5
Bitrix\Seo\Retargeting\Services\ResponseGoogle
Definition
responsegoogle.php:12
Bitrix\Seo\Retargeting\Services\ResponseGoogle\TYPE_CODE
const TYPE_CODE
Definition
responsegoogle.php:13
Bitrix\Seo\Retargeting\Services\ResponseGoogle\getSkippedErrorCodes
getSkippedErrorCodes()
Definition
responsegoogle.php:15
Bitrix\Seo\Retargeting\Services\ResponseGoogle\parse
parse($data)
Definition
responsegoogle.php:22
Bitrix\Seo\Retargeting\Services
Definition
accountfacebook.php:3
modules
seo
lib
retargeting
services
responsegoogle.php
Создано системой
1.10.0