Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
responsevkads.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\Text\Encoding
;
8
use \Bitrix\Main\Web\Json;
9
use \Bitrix\Seo\Retargeting\Response;
10
11
Loc::loadMessages
(__FILE__);
12
class
ResponseVkads
extends
Response
13
{
14
const
TYPE_CODE
=
'vkads'
;
15
16
public
function
parse
($data)
17
{
18
// Need for preserve double UTF-conversion, because VK return JSON answer in result
19
if
(is_string($data))
20
{
21
$data = Encoding::convertEncoding($data, SITE_CHARSET,
'UTF-8'
);
22
}
23
24
$parsed = is_array($data) ? $data : Json::decode($data);
25
if
($parsed[
'error'
])
26
{
27
$errorMessage = $parsed[
'error'
][
'error_msg'
];
28
if
((
string
)$parsed[
'error'
][
'error_code'
] ===
'100'
)
29
{
30
$errorMessage =
Loc::getMessage
(
31
'SEO_RETARGETING_SERVICE_RESPONSE_VKONTAKTE_ERROR_100'
,
32
[
33
'%code%'
=> htmlspecialcharsbx($parsed[
'error'
][
'error_code'
]),
34
'%msg%'
=> htmlspecialcharsbx($parsed[
'error'
][
'error_msg'
]),
35
]
36
);
37
}
38
39
$errorMessage =
Loc::getMessage
(
'SEO_RETARGETING_SERVICE_RESPONSE_VKONTAKTE_ERROR'
)
40
.
': '
41
. $errorMessage;
42
$this->addError(
new
Error
($errorMessage, $parsed[
'error'
][
'error_code'
]));
43
}
44
45
$result = [];
46
if
($parsed[
'response'
])
47
{
48
$result = $parsed[
'response'
];
49
}
50
elseif(!isset($parsed[
'error'
]))
51
{
52
$result = $parsed;
53
}
54
55
$this->setData(is_array($result) ? $result : [$result]);
56
}
57
}
Bitrix\Main\Error
Definition
error.php:14
Bitrix\Main\Localization\Loc\loadMessages
static loadMessages($file)
Definition
loc.php:64
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Main\Response
Definition
response.php:5
Bitrix\Main\Text\Encoding
Definition
encoding.php:8
Bitrix\Seo\Retargeting\Services\ResponseVkads
Definition
responsevkads.php:13
Bitrix\Seo\Retargeting\Services\ResponseVkads\TYPE_CODE
const TYPE_CODE
Definition
responsevkads.php:14
Bitrix\Seo\Retargeting\Services\ResponseVkads\parse
parse($data)
Definition
responsevkads.php:16
Bitrix\Seo\Retargeting\Services
Definition
accountfacebook.php:3
modules
seo
lib
retargeting
services
responsevkads.php
Создано системой
1.10.0