1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace FreedomCore\VK\API; |
4
|
|
|
|
5
|
|
|
use FreedomCore\VK\VKBase; |
6
|
|
|
|
7
|
|
|
class VKAccount extends VKAPI { |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* API Method for this class |
11
|
|
|
* @var string |
12
|
|
|
*/ |
13
|
|
|
protected $apiMethod = 'account.'; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Default Filters To Be Used |
17
|
|
|
*/ |
18
|
|
|
const defaultFilters = [ 'friends', 'messages', 'groups' ]; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* VKAccount constructor. |
22
|
|
|
* @param VKBase $vkObject |
23
|
|
|
*/ |
24
|
|
|
public function __construct(VKBase $vkObject) { |
25
|
|
|
parent::__construct($vkObject); |
26
|
|
|
parent::isAllowed(); |
|
|
|
|
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Returns non-null values of user counters |
31
|
|
|
* @param array $selectedFilters |
32
|
|
|
* @return array |
33
|
|
|
*/ |
34
|
|
|
public function getCounters($selectedFilters = self::defaultFilters) { |
35
|
|
|
$requestParameters = [ |
36
|
|
|
'filter' => $this->getAllowedFilters($selectedFilters) |
37
|
|
|
]; |
38
|
|
|
|
39
|
|
|
return parent::executeQuery(__FUNCTION__, $requestParameters); |
|
|
|
|
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Sets an application screen name (up to 17 characters), that is shown to the user in the left menu. |
44
|
|
|
* @param $userID |
45
|
|
|
* @param $applicationName |
46
|
|
|
* @return mixed |
47
|
|
|
*/ |
48
|
|
|
public function setNameInMenu($userID, $applicationName) { |
49
|
|
|
$requestParameters = [ |
50
|
|
|
'user_id' => $userID, |
51
|
|
|
'name' => $applicationName |
52
|
|
|
]; |
53
|
|
|
|
54
|
|
|
return parent::executeQuery(__FUNCTION__, $requestParameters); |
|
|
|
|
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Marks the current user as online for 15 minutes. |
59
|
|
|
* (This method is available only to standalone-applications.) |
60
|
|
|
* @return mixed |
61
|
|
|
*/ |
62
|
|
|
public function setOnline() { |
63
|
|
|
$requestParameters = [ |
64
|
|
|
'voip' => 1 |
65
|
|
|
]; |
66
|
|
|
return $this->executeQuery(__FUNCTION__, $requestParameters); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Marks a current user as Offline. |
71
|
|
|
* (This method is available only to standalone-applications.) |
72
|
|
|
* @return mixed |
73
|
|
|
*/ |
74
|
|
|
public function setOffline() { |
75
|
|
|
return $this->executeQuery(__FUNCTION__, [ ]); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* Returns a list of active ads (offers) which executed by the user will bring him/her respective number of votes to his balance in the application. |
80
|
|
|
* @param int $setOffset |
81
|
|
|
* @param int $setCount |
82
|
|
|
* @return array |
83
|
|
|
*/ |
84
|
|
|
public function getActiveOffers($setOffset = 0, $setCount = 100) { |
85
|
|
|
$requestParameters = [ |
86
|
|
|
'offset' => $setOffset, |
87
|
|
|
'count' => ($setCount > 100 || $setCount < 0) ? 100 : $setCount |
88
|
|
|
]; |
89
|
|
|
|
90
|
|
|
return parent::executeQuery(__FUNCTION__, $requestParameters); |
|
|
|
|
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* Gets settings of the current user in this application. |
95
|
|
|
* @param int $userID |
96
|
|
|
* @return mixed |
97
|
|
|
*/ |
98
|
|
|
public function getAppPermissions($userID) { |
99
|
|
|
$requestParameters = [ |
100
|
|
|
'user_id' => $userID |
101
|
|
|
]; |
102
|
|
|
|
103
|
|
|
return parent::executeQuery(__FUNCTION__, $requestParameters); |
|
|
|
|
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* Get String of Filters Which Are Allowed To Be Used |
108
|
|
|
* @param $filtersArray |
109
|
|
|
* @return string |
110
|
|
|
*/ |
111
|
|
|
private function getAllowedFilters($filtersArray) { |
112
|
|
|
$existingFilters = [ |
113
|
|
|
'friends', |
114
|
|
|
'messages', |
115
|
|
|
'photos', |
116
|
|
|
'videos', |
117
|
|
|
'notes', |
118
|
|
|
'gifts', |
119
|
|
|
'events', |
120
|
|
|
'groups', |
121
|
|
|
'sdk' |
122
|
|
|
]; |
123
|
|
|
|
124
|
|
|
foreach ($filtersArray as $fKey => $fValue) { |
125
|
|
|
if (!in_array($fValue, $existingFilters)) { |
126
|
|
|
unset($filtersArray[ $fKey ]); |
127
|
|
|
} |
128
|
|
|
} |
129
|
|
|
return implode(',', $filtersArray); |
130
|
|
|
} |
131
|
|
|
} |
This check looks for a call to a parent method whose name is different than the method from which it is called.
Consider the following code:
The
getFirstName()
method in theSon
calls the wrong method in the parent class.