Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
responsevkontakte.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
ResponseVkontakte
extends
Response
13
{
14
const
TYPE_CODE
=
'vkontakte'
;
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
switch
((
string
) $parsed[
'error'
][
'error_code'
])
29
{
30
case
'100'
:
31
$errorMessage =
Loc::getMessage
(
32
'SEO_RETARGETING_SERVICE_RESPONSE_VKONTAKTE_ERROR_100'
,
33
array(
34
'%code%'
=> htmlspecialcharsbx($parsed[
'error'
][
'error_code'
]),
35
'%msg%'
=> htmlspecialcharsbx($parsed[
'error'
][
'error_msg'
]),
36
)
37
);
38
break
;
39
}
40
41
$errorMessage =
Loc::getMessage
(
'SEO_RETARGETING_SERVICE_RESPONSE_VKONTAKTE_ERROR'
)
42
.
': '
43
. $errorMessage;
44
$this->addError(
new
Error
($errorMessage, $parsed[
'error'
][
'error_code'
]));
45
}
46
47
$result = array();
48
if
($parsed[
'response'
])
49
{
50
$result = $parsed[
'response'
];
51
}
52
else
if
(!isset($parsed[
'error'
]))
53
{
54
$result = $parsed;
55
}
56
57
$this->setData(is_array($result) ? $result : array($result));
58
}
59
}
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\ResponseVkontakte
Definition
responsevkontakte.php:13
Bitrix\Seo\Retargeting\Services\ResponseVkontakte\TYPE_CODE
const TYPE_CODE
Definition
responsevkontakte.php:14
Bitrix\Seo\Retargeting\Services\ResponseVkontakte\parse
parse($data)
Definition
responsevkontakte.php:16
Bitrix\Seo\Retargeting\Services
Definition
accountfacebook.php:3
modules
seo
lib
retargeting
services
responsevkontakte.php
Создано системой
1.10.0