Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
accountfacebook.php
1
<?php
2
3
namespace
Bitrix\Seo\LeadAds\Services
;
4
5
use
Bitrix\Seo\LeadAds\Account
;
6
use
Bitrix\Seo\LeadAds
;
7
use
Bitrix\Seo\Retargeting\Paginator
;
8
9
class
AccountFacebook
extends
Account
10
{
11
public
const
TYPE_CODE
= LeadAds\Service::TYPE_FACEBOOK;
12
13
public
const
URL_ACCOUNT_LIST
=
'https://www.facebook.com/bookmarks/pages'
;
14
15
public
const
URL_INFO
=
'https://www.facebook.com/business/a/lead-ads'
;
16
17
protected
static
$listRowMap
= array(
18
'ID'
=>
'ID'
,
19
'NAME'
=>
'NAME'
,
20
);
21
25
public
function
getList
()
26
{
27
$paginator =
new
Paginator
(
28
$this->
getRequest
(),
29
[
30
'methodName'
=>
'leadads.accounts.get'
,
31
'parameters'
=> [
32
'fields'
=> [
'id'
,
'name'
,
'category'
,
'access_token'
,
'tasks'
],
33
"params"
=> [
34
"limit"
=> 50
35
]
36
],
37
]
38
);
39
40
$result =
null
;
41
$data = [];
42
43
foreach
($paginator as
$request
)
44
{
45
if
(!
$request
->isSuccess())
46
{
47
return
$request
;
48
}
49
50
foreach
(
$request
->getData() as $item)
51
{
52
if
(array_intersect($item[
'tasks'
] ?? [], [
'MODERATE'
,
'CREATE_CONTENT'
,
'MANAGE'
]))
53
{
54
$data[] = $item;
55
}
56
}
57
$result =
$request
;
58
}
59
60
!$result?:$result->setData($data);
61
62
return
$result;
63
}
64
69
public
function
getProfile
(): ?array
70
{
71
$response = $this->
getRequest
()->send([
72
'methodName'
=>
'leadads.profile.get'
,
73
'parameters'
=> [
74
'fields'
=> [
'id'
,
'name'
,
'picture'
,
'link'
]
75
]
76
]);
77
78
if
($response->isSuccess() && $data = $response->fetch())
79
{
80
81
return
[
82
'ID'
=> $data[
'ID'
],
83
'NAME'
=> $data[
'NAME'
],
84
'LINK'
=> $data[
'LINK'
],
85
'PICTURE'
=> $data[
'PICTURE'
] ? $data[
'PICTURE'
][
'data'
][
'url'
] :
null
,
86
];
87
}
88
89
return
null
;
90
}
91
}
Bitrix\Seo\LeadAds\Account
Definition
account.php:13
Bitrix\Seo\LeadAds\Services\AccountFacebook
Definition
accountfacebook.php:10
Bitrix\Seo\LeadAds\Services\AccountFacebook\$listRowMap
static $listRowMap
Definition
accountfacebook.php:17
Bitrix\Seo\LeadAds\Services\AccountFacebook\TYPE_CODE
const TYPE_CODE
Definition
accountfacebook.php:11
Bitrix\Seo\LeadAds\Services\AccountFacebook\URL_ACCOUNT_LIST
const URL_ACCOUNT_LIST
Definition
accountfacebook.php:13
Bitrix\Seo\LeadAds\Services\AccountFacebook\URL_INFO
const URL_INFO
Definition
accountfacebook.php:15
Bitrix\Seo\LeadAds\Services\AccountFacebook\getList
getList()
Definition
accountfacebook.php:25
Bitrix\Seo\LeadAds\Services\AccountFacebook\getProfile
getProfile()
Definition
accountfacebook.php:69
Bitrix\Seo\Retargeting\BaseApiObject\$request
$request
Definition
baseapiobject.php:10
Bitrix\Seo\Retargeting\BaseApiObject\getRequest
getRequest()
Definition
baseapiobject.php:44
Bitrix\Seo\Retargeting\Paginator
Definition
paginator.php:6
Bitrix\Seo\LeadAds\Services
Definition
accountfacebook.php:3
Bitrix\Seo\LeadAds
Definition
account.php:3
modules
seo
lib
leadads
services
accountfacebook.php
Создано системой
1.10.0