Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
responsefacebook.php
1
<?php
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\PagingInterface
;
9
use \Bitrix\Seo\Retargeting\Response;
10
11
Loc::loadMessages
(__FILE__);
12
13
class
ResponseFacebook
extends
Response
implements
PagingInterface
14
{
15
public
const
TYPE_CODE
=
'facebook'
;
16
18
protected
$pagingData
;
19
26
public
function
parse
($data) : void
27
{
28
$parsed = is_array($data) ? $data : Json::decode($data);
29
30
if
($parsed[
'error'
])
31
{
32
$errorText = (isset($parsed[
'error'
][
'error_user_msg'
]) && $parsed[
'error'
][
'error_user_msg'
])
33
? $parsed[
'error'
][
'error_user_msg'
]
34
: $parsed[
'error'
][
'message'
]
35
;
36
37
if
($errorText ===
'(#100) The parameter follow_up_action_url is required'
)
38
{
39
$errorText =
Loc::getMessage
(
'SEO_RETARGETING_SERVICE_RESPONSE_FACEBOOK_ERROR_URL_REQUIRED'
);
40
}
41
if
($errorText ===
'To create or edit a Custom Audience made from a customer list, your admin needs to add this ad account to a business.'
)
42
{
43
$errorText =
Loc::getMessage
(
'SEO_RETARGETING_SERVICE_RESPONSE_FACEBOOK_ERROR_ADD_TO_BUSINESS'
);
44
}
45
46
$this->addError(
47
new
Error
(
48
Loc::getMessage
(
'SEO_RETARGETING_SERVICE_RESPONSE_FACEBOOK_ERROR'
) .
': '
. $errorText,
49
$parsed[
'error'
][
'code'
]
50
)
51
);
52
}
53
54
if
($parsed[
'data'
])
55
{
56
$this->setData($parsed[
'data'
]);
57
}
58
elseif (!isset($parsed[
'error'
]))
59
{
60
$this->setData($parsed);
61
}
62
63
if
(isset($parsed[
'paging'
]))
64
{
65
$this->pagingData = $parsed[
'paging'
];
66
}
67
}
68
75
public
function
prepareRequestParams
(array $params) : ?array
76
{
77
if
(isset($this->pagingData[
'next'
], $this->pagingData[
'cursors'
][
'after'
]))
78
{
79
$params[
'parameters'
][
'params'
][
'after'
] = $this->pagingData[
'cursors'
][
'after'
];
80
81
return
$params;
82
}
83
84
return
null
;
85
}
86
}
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\Seo\Retargeting\Services\ResponseFacebook
Definition
responsefacebook.php:14
Bitrix\Seo\Retargeting\Services\ResponseFacebook\prepareRequestParams
prepareRequestParams(array $params)
Definition
responsefacebook.php:75
Bitrix\Seo\Retargeting\Services\ResponseFacebook\$pagingData
$pagingData
Definition
responsefacebook.php:18
Bitrix\Seo\Retargeting\Services\ResponseFacebook\TYPE_CODE
const TYPE_CODE
Definition
responsefacebook.php:15
Bitrix\Seo\Retargeting\Services\ResponseFacebook\parse
parse($data)
Definition
responsefacebook.php:26
Bitrix\Seo\Retargeting\PagingInterface
Definition
paginginterface.php:6
Bitrix\Seo\Retargeting\Services
Definition
accountfacebook.php:3
modules
seo
lib
retargeting
services
responsefacebook.php
Создано системой
1.10.0