@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | /** |
| 52 | 52 | * Is User Authorized To Make an API Request |
| 53 | 53 | * @param int $requiredPermission |
| 54 | - * @return bool |
|
| 54 | + * @return boolean|null |
|
| 55 | 55 | * @throws VKException |
| 56 | 56 | */ |
| 57 | 57 | protected function isAllowed($requiredPermission = null){ |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | |
| 78 | 78 | /** |
| 79 | 79 | * Execute API Call |
| 80 | - * @param $apiMethod |
|
| 80 | + * @param string $apiMethod |
|
| 81 | 81 | * @param $requestParameters |
| 82 | 82 | * @return mixed |
| 83 | 83 | */ |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | * VKUsers constructor. |
| 45 | 45 | * @param VKBase $vkObject |
| 46 | 46 | */ |
| 47 | - public function __construct(VKBase $vkObject){ |
|
| 47 | + public function __construct(VKBase $vkObject) { |
|
| 48 | 48 | $this->VKObject = $vkObject; |
| 49 | 49 | } |
| 50 | 50 | |
@@ -54,22 +54,22 @@ discard block |
||
| 54 | 54 | * @return bool |
| 55 | 55 | * @throws VKException |
| 56 | 56 | */ |
| 57 | - protected function isAllowed($requiredPermission = null){ |
|
| 58 | - if($requiredPermission != null){ |
|
| 57 | + protected function isAllowed($requiredPermission = null) { |
|
| 58 | + if ($requiredPermission != null) { |
|
| 59 | 59 | try { |
| 60 | 60 | $isValidPermission = $this->VKObject->getPermissionsMask() & $requiredPermission; |
| 61 | - if(!$isValidPermission) |
|
| 61 | + if (!$isValidPermission) |
|
| 62 | 62 | throw new VKException('Insufficient Permissions Received!', 1); |
| 63 | - } catch (VKException $ex){ |
|
| 63 | + } catch (VKException $ex) { |
|
| 64 | 64 | echo $ex->getMessage(); |
| 65 | 65 | die(); |
| 66 | 66 | } |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | try { |
| 70 | - if(!$this->VKObject->isAuthorized()) |
|
| 70 | + if (!$this->VKObject->isAuthorized()) |
|
| 71 | 71 | throw new VKException('User not Authorized to make this API Request!', 1); |
| 72 | - } catch (VKException $ex){ |
|
| 72 | + } catch (VKException $ex) { |
|
| 73 | 73 | echo $ex->getMessage(); |
| 74 | 74 | die(); |
| 75 | 75 | } |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | * @param $requestParameters |
| 82 | 82 | * @return mixed |
| 83 | 83 | */ |
| 84 | - protected function executeQuery($apiMethod, $requestParameters){ |
|
| 84 | + protected function executeQuery($apiMethod, $requestParameters) { |
|
| 85 | 85 | return $this->VKObject->apiQuery($this->apiMethod.$apiMethod, $requestParameters); |
| 86 | 86 | } |
| 87 | 87 | } |
| 88 | 88 | \ No newline at end of file |
@@ -58,8 +58,9 @@ discard block |
||
| 58 | 58 | if($requiredPermission != null){ |
| 59 | 59 | try { |
| 60 | 60 | $isValidPermission = $this->VKObject->getPermissionsMask() & $requiredPermission; |
| 61 | - if(!$isValidPermission) |
|
| 62 | - throw new VKException('Insufficient Permissions Received!', 1); |
|
| 61 | + if(!$isValidPermission) { |
|
| 62 | + throw new VKException('Insufficient Permissions Received!', 1); |
|
| 63 | + } |
|
| 63 | 64 | } catch (VKException $ex){ |
| 64 | 65 | echo $ex->getMessage(); |
| 65 | 66 | die(); |
@@ -67,8 +68,9 @@ discard block |
||
| 67 | 68 | } |
| 68 | 69 | |
| 69 | 70 | try { |
| 70 | - if(!$this->VKObject->isAuthorized()) |
|
| 71 | - throw new VKException('User not Authorized to make this API Request!', 1); |
|
| 71 | + if(!$this->VKObject->isAuthorized()) { |
|
| 72 | + throw new VKException('User not Authorized to make this API Request!', 1); |
|
| 73 | + } |
|
| 72 | 74 | } catch (VKException $ex){ |
| 73 | 75 | echo $ex->getMessage(); |
| 74 | 76 | die(); |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | /** |
| 34 | 34 | * Returns detailed information on users |
| 35 | - * @param array $usersIDs |
|
| 35 | + * @param string[] $usersIDs |
|
| 36 | 36 | * @param array $requestFields |
| 37 | 37 | * @param string $nameCase |
| 38 | 38 | * @return mixed |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | /** |
| 171 | 171 | * Return fields which are allowed to be used |
| 172 | 172 | * @param $fieldsArray |
| 173 | - * @return mixed |
|
| 173 | + * @return string |
|
| 174 | 174 | */ |
| 175 | 175 | private function returnAllowedFields($fieldsArray){ |
| 176 | 176 | $allowedFields = ['photo_id', 'verified', 'sex', 'bdate', 'city', 'country', 'home_town', 'has_photo', 'photo_50', 'photo_100', 'photo_200_orig', 'photo_200', 'photo_400_orig', 'photo_max', 'photo_max_orig', 'online', 'lists', 'domain', 'has_mobile', 'contacts', 'site', 'education', 'universities', 'schools', 'status', 'last_seen', 'followers_count', 'common_count', 'occupation', 'nickname', 'relatives', 'relation', 'personal', 'connections', 'exports', 'wall_comments', 'activities', 'interests', 'music', 'movies', 'tv', 'books', 'games', 'about', 'quotes', 'can_post', 'can_see_all_posts', 'can_see_audio', 'can_write_private_message', 'can_send_friend_request', 'is_favorite', 'is_hidden_from_feed', 'timezone', 'screen_name', 'maiden_name', 'crop_photo', 'is_friend', 'friend_status', 'career', 'military', 'blacklisted', 'blacklisted_by_me']; |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | |
| 181 | 181 | /** |
| 182 | 182 | * Return Allowed Name Case |
| 183 | - * @param $ncValue |
|
| 183 | + * @param string $ncValue |
|
| 184 | 184 | * @return string |
| 185 | 185 | */ |
| 186 | 186 | private function returnAllowedNC($ncValue){ |
@@ -20,13 +20,13 @@ discard block |
||
| 20 | 20 | /** |
| 21 | 21 | * Default Fields For Selection |
| 22 | 22 | */ |
| 23 | - const standardFields = ['sex', 'online', 'country', 'city', 'bdate']; |
|
| 23 | + const standardFields = [ 'sex', 'online', 'country', 'city', 'bdate' ]; |
|
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | 26 | * VKUsers constructor. |
| 27 | 27 | * @param VKBase $vkObject |
| 28 | 28 | */ |
| 29 | - public function __construct(VKBase $vkObject){ |
|
| 29 | + public function __construct(VKBase $vkObject) { |
|
| 30 | 30 | parent::__construct($vkObject); |
| 31 | 31 | } |
| 32 | 32 | |
@@ -40,13 +40,13 @@ discard block |
||
| 40 | 40 | */ |
| 41 | 41 | public function get($usersIDs, $requestFields = self::standardFields, $nameCase = 'nom') { |
| 42 | 42 | parent::isAllowed(); |
| 43 | - if(!is_array($usersIDs)) |
|
| 43 | + if (!is_array($usersIDs)) |
|
| 44 | 44 | throw new VKException('First Parameters Must Be Represented By Array Of Users IDs', 1); |
| 45 | - if(!is_array($requestFields)) |
|
| 45 | + if (!is_array($requestFields)) |
|
| 46 | 46 | throw new VKException('Second Parameters Must Be Represented By Array Of Fields To Be Requested', 1); |
| 47 | 47 | |
| 48 | 48 | $requestParameters = [ |
| 49 | - 'user_ids' => implode(',',$usersIDs), |
|
| 49 | + 'user_ids' => implode(',', $usersIDs), |
|
| 50 | 50 | 'fields' => $this->returnAllowedFields($requestFields), |
| 51 | 51 | 'name_case' => $this->returnAllowedNC($nameCase) |
| 52 | 52 | ]; |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | */ |
| 67 | 67 | public function search($searchQuery, $isOnline = 1, $requestFields = self::standardFields, $sortBy = 0, $displayCount = 5) { |
| 68 | 68 | parent::isAllowed(); |
| 69 | - if(!is_array($requestFields)) |
|
| 69 | + if (!is_array($requestFields)) |
|
| 70 | 70 | throw new VKException('Forth Parameters Must Be Represented By Array Of Fields To Be Requested', 1); |
| 71 | 71 | $requestFields = $this->returnAllowedFields($requestFields); |
| 72 | 72 | $sortBy = ($sortBy > 1 || $sortBy < 0) ? 0 : $sortBy; |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | * @return mixed |
| 90 | 90 | * @throws VKException |
| 91 | 91 | */ |
| 92 | - public function isAppUser($userID){ |
|
| 92 | + public function isAppUser($userID) { |
|
| 93 | 93 | parent::isAllowed(); |
| 94 | 94 | $requestParameters = [ |
| 95 | 95 | 'user_id' => $userID |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | * @return mixed |
| 108 | 108 | * @throws VKException |
| 109 | 109 | */ |
| 110 | - public function getSubscriptions($userID, $combineResults = 0, $requestFields = self::standardFields, $resultCount = 20){ |
|
| 110 | + public function getSubscriptions($userID, $combineResults = 0, $requestFields = self::standardFields, $resultCount = 20) { |
|
| 111 | 111 | parent::isAllowed(); |
| 112 | 112 | $requestParameters = [ |
| 113 | 113 | 'user_id' => $userID, |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | * @return mixed |
| 130 | 130 | * @throws VKException |
| 131 | 131 | */ |
| 132 | - public function getFollowers($userID, $setOffset = 0, $displayCount = 100, $requestFields = self::standardFields, $nameCase = 'nom'){ |
|
| 132 | + public function getFollowers($userID, $setOffset = 0, $displayCount = 100, $requestFields = self::standardFields, $nameCase = 'nom') { |
|
| 133 | 133 | parent::isAllowed(); |
| 134 | 134 | $requestParameters = [ |
| 135 | 135 | 'user_id' => $userID, |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | * @return mixed |
| 154 | 154 | * @throws VKException |
| 155 | 155 | */ |
| 156 | - public function getNearby($currentLatitude, $currentLongitude, $setTimeOut = 7200, $setRadius = 1, $requestFields = self::standardFields, $nameCase = 'nom'){ |
|
| 156 | + public function getNearby($currentLatitude, $currentLongitude, $setTimeOut = 7200, $setRadius = 1, $requestFields = self::standardFields, $nameCase = 'nom') { |
|
| 157 | 157 | parent::isAllowed(); |
| 158 | 158 | $requestParameters = [ |
| 159 | 159 | 'latitude' => $currentLatitude, |
@@ -172,9 +172,9 @@ discard block |
||
| 172 | 172 | * @param $fieldsArray |
| 173 | 173 | * @return mixed |
| 174 | 174 | */ |
| 175 | - private function returnAllowedFields($fieldsArray){ |
|
| 176 | - $allowedFields = ['photo_id', 'verified', 'sex', 'bdate', 'city', 'country', 'home_town', 'has_photo', 'photo_50', 'photo_100', 'photo_200_orig', 'photo_200', 'photo_400_orig', 'photo_max', 'photo_max_orig', 'online', 'lists', 'domain', 'has_mobile', 'contacts', 'site', 'education', 'universities', 'schools', 'status', 'last_seen', 'followers_count', 'common_count', 'occupation', 'nickname', 'relatives', 'relation', 'personal', 'connections', 'exports', 'wall_comments', 'activities', 'interests', 'music', 'movies', 'tv', 'books', 'games', 'about', 'quotes', 'can_post', 'can_see_all_posts', 'can_see_audio', 'can_write_private_message', 'can_send_friend_request', 'is_favorite', 'is_hidden_from_feed', 'timezone', 'screen_name', 'maiden_name', 'crop_photo', 'is_friend', 'friend_status', 'career', 'military', 'blacklisted', 'blacklisted_by_me']; |
|
| 177 | - foreach($fieldsArray as $fKey => $fValue){ if(!in_array($fValue, $allowedFields)) unset($fieldsArray[$fKey]); } |
|
| 175 | + private function returnAllowedFields($fieldsArray) { |
|
| 176 | + $allowedFields = [ 'photo_id', 'verified', 'sex', 'bdate', 'city', 'country', 'home_town', 'has_photo', 'photo_50', 'photo_100', 'photo_200_orig', 'photo_200', 'photo_400_orig', 'photo_max', 'photo_max_orig', 'online', 'lists', 'domain', 'has_mobile', 'contacts', 'site', 'education', 'universities', 'schools', 'status', 'last_seen', 'followers_count', 'common_count', 'occupation', 'nickname', 'relatives', 'relation', 'personal', 'connections', 'exports', 'wall_comments', 'activities', 'interests', 'music', 'movies', 'tv', 'books', 'games', 'about', 'quotes', 'can_post', 'can_see_all_posts', 'can_see_audio', 'can_write_private_message', 'can_send_friend_request', 'is_favorite', 'is_hidden_from_feed', 'timezone', 'screen_name', 'maiden_name', 'crop_photo', 'is_friend', 'friend_status', 'career', 'military', 'blacklisted', 'blacklisted_by_me' ]; |
|
| 177 | + foreach ($fieldsArray as $fKey => $fValue) { if (!in_array($fValue, $allowedFields)) unset($fieldsArray[ $fKey ]); } |
|
| 178 | 178 | return implode(',', $fieldsArray); |
| 179 | 179 | } |
| 180 | 180 | |
@@ -183,9 +183,9 @@ discard block |
||
| 183 | 183 | * @param $ncValue |
| 184 | 184 | * @return string |
| 185 | 185 | */ |
| 186 | - private function returnAllowedNC($ncValue){ |
|
| 187 | - $allowedNameCases = ['nom', 'gen', 'dat', 'acc', 'ins', 'abl']; |
|
| 188 | - if(!in_array($ncValue, $allowedNameCases)) $ncValue = 'nom'; |
|
| 186 | + private function returnAllowedNC($ncValue) { |
|
| 187 | + $allowedNameCases = [ 'nom', 'gen', 'dat', 'acc', 'ins', 'abl' ]; |
|
| 188 | + if (!in_array($ncValue, $allowedNameCases)) $ncValue = 'nom'; |
|
| 189 | 189 | return $ncValue; |
| 190 | 190 | } |
| 191 | 191 | } |
| 192 | 192 | \ No newline at end of file |
@@ -40,10 +40,12 @@ discard block |
||
| 40 | 40 | */ |
| 41 | 41 | public function get($usersIDs, $requestFields = self::standardFields, $nameCase = 'nom') { |
| 42 | 42 | parent::isAllowed(); |
| 43 | - if(!is_array($usersIDs)) |
|
| 44 | - throw new VKException('First Parameters Must Be Represented By Array Of Users IDs', 1); |
|
| 45 | - if(!is_array($requestFields)) |
|
| 46 | - throw new VKException('Second Parameters Must Be Represented By Array Of Fields To Be Requested', 1); |
|
| 43 | + if(!is_array($usersIDs)) { |
|
| 44 | + throw new VKException('First Parameters Must Be Represented By Array Of Users IDs', 1); |
|
| 45 | + } |
|
| 46 | + if(!is_array($requestFields)) { |
|
| 47 | + throw new VKException('Second Parameters Must Be Represented By Array Of Fields To Be Requested', 1); |
|
| 48 | + } |
|
| 47 | 49 | |
| 48 | 50 | $requestParameters = [ |
| 49 | 51 | 'user_ids' => implode(',',$usersIDs), |
@@ -66,8 +68,9 @@ discard block |
||
| 66 | 68 | */ |
| 67 | 69 | public function search($searchQuery, $isOnline = 1, $requestFields = self::standardFields, $sortBy = 0, $displayCount = 5) { |
| 68 | 70 | parent::isAllowed(); |
| 69 | - if(!is_array($requestFields)) |
|
| 70 | - throw new VKException('Forth Parameters Must Be Represented By Array Of Fields To Be Requested', 1); |
|
| 71 | + if(!is_array($requestFields)) { |
|
| 72 | + throw new VKException('Forth Parameters Must Be Represented By Array Of Fields To Be Requested', 1); |
|
| 73 | + } |
|
| 71 | 74 | $requestFields = $this->returnAllowedFields($requestFields); |
| 72 | 75 | $sortBy = ($sortBy > 1 || $sortBy < 0) ? 0 : $sortBy; |
| 73 | 76 | $isOnline = ($isOnline > 1 || $isOnline < 0) ? 1 : $isOnline; |
@@ -174,7 +177,10 @@ discard block |
||
| 174 | 177 | */ |
| 175 | 178 | private function returnAllowedFields($fieldsArray){ |
| 176 | 179 | $allowedFields = ['photo_id', 'verified', 'sex', 'bdate', 'city', 'country', 'home_town', 'has_photo', 'photo_50', 'photo_100', 'photo_200_orig', 'photo_200', 'photo_400_orig', 'photo_max', 'photo_max_orig', 'online', 'lists', 'domain', 'has_mobile', 'contacts', 'site', 'education', 'universities', 'schools', 'status', 'last_seen', 'followers_count', 'common_count', 'occupation', 'nickname', 'relatives', 'relation', 'personal', 'connections', 'exports', 'wall_comments', 'activities', 'interests', 'music', 'movies', 'tv', 'books', 'games', 'about', 'quotes', 'can_post', 'can_see_all_posts', 'can_see_audio', 'can_write_private_message', 'can_send_friend_request', 'is_favorite', 'is_hidden_from_feed', 'timezone', 'screen_name', 'maiden_name', 'crop_photo', 'is_friend', 'friend_status', 'career', 'military', 'blacklisted', 'blacklisted_by_me']; |
| 177 | - foreach($fieldsArray as $fKey => $fValue){ if(!in_array($fValue, $allowedFields)) unset($fieldsArray[$fKey]); } |
|
| 180 | + foreach($fieldsArray as $fKey => $fValue){ if(!in_array($fValue, $allowedFields)) { |
|
| 181 | + unset($fieldsArray[$fKey]); |
|
| 182 | + } |
|
| 183 | + } |
|
| 178 | 184 | return implode(',', $fieldsArray); |
| 179 | 185 | } |
| 180 | 186 | |
@@ -185,7 +191,9 @@ discard block |
||
| 185 | 191 | */ |
| 186 | 192 | private function returnAllowedNC($ncValue){ |
| 187 | 193 | $allowedNameCases = ['nom', 'gen', 'dat', 'acc', 'ins', 'abl']; |
| 188 | - if(!in_array($ncValue, $allowedNameCases)) $ncValue = 'nom'; |
|
| 194 | + if(!in_array($ncValue, $allowedNameCases)) { |
|
| 195 | + $ncValue = 'nom'; |
|
| 196 | + } |
|
| 189 | 197 | return $ncValue; |
| 190 | 198 | } |
| 191 | 199 | } |
| 192 | 200 | \ No newline at end of file |
@@ -332,7 +332,7 @@ |
||
| 332 | 332 | |
| 333 | 333 | /** |
| 334 | 334 | * Convert INT Code To Full Description |
| 335 | - * @param $Code |
|
| 335 | + * @param integer $Code |
|
| 336 | 336 | * @return mixed |
| 337 | 337 | */ |
| 338 | 338 | private function codeToErrorText($Code){ |
@@ -86,17 +86,17 @@ discard block |
||
| 86 | 86 | * @param string $accessToken |
| 87 | 87 | * @throws VKException |
| 88 | 88 | */ |
| 89 | - public function __construct($appID, $apiSecret, $accessToken = null){ |
|
| 89 | + public function __construct($appID, $apiSecret, $accessToken = null) { |
|
| 90 | 90 | $this->applicationID = $appID; |
| 91 | 91 | $this->APISecret = $apiSecret; |
| 92 | 92 | $this->accessToken = $accessToken; |
| 93 | 93 | $this->curlObject = curl_init(); |
| 94 | - if(!is_null($accessToken)){ |
|
| 95 | - if(!$this->isPermissionsMaskSet){ |
|
| 94 | + if (!is_null($accessToken)) { |
|
| 95 | + if (!$this->isPermissionsMaskSet) { |
|
| 96 | 96 | $VKUser = new VKUsers($this); |
| 97 | 97 | $VKAccount = new VKAccount($this); |
| 98 | - $CurrentUser = $VKUser->get([''])['response'][0]['uid']; |
|
| 99 | - $this->setPermissionsMask($VKAccount->getAppPermissions($CurrentUser)['response']); |
|
| 98 | + $CurrentUser = $VKUser->get([ '' ])[ 'response' ][ 0 ][ 'uid' ]; |
|
| 99 | + $this->setPermissionsMask($VKAccount->getAppPermissions($CurrentUser)[ 'response' ]); |
|
| 100 | 100 | $this->isPermissionsMaskSet = true; |
| 101 | 101 | unset($VKUser); |
| 102 | 102 | unset($VKAccount); |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | * Set API Version Provided By User |
| 116 | 116 | * @param int $apiVersion |
| 117 | 117 | */ |
| 118 | - public function setAPIVersion($apiVersion){ |
|
| 118 | + public function setAPIVersion($apiVersion) { |
|
| 119 | 119 | $this->APIVersion = $apiVersion; |
| 120 | 120 | } |
| 121 | 121 | |
@@ -125,8 +125,8 @@ discard block |
||
| 125 | 125 | * @param string $responseFormat |
| 126 | 126 | * @return string |
| 127 | 127 | */ |
| 128 | - public function getAPIUrl($apiMethod, $responseFormat = 'json'){ |
|
| 129 | - return self::METHOD_URL . $apiMethod . '.' . $responseFormat; |
|
| 128 | + public function getAPIUrl($apiMethod, $responseFormat = 'json') { |
|
| 129 | + return self::METHOD_URL.$apiMethod.'.'.$responseFormat; |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | /** |
@@ -137,8 +137,8 @@ discard block |
||
| 137 | 137 | * @param bool $testMode |
| 138 | 138 | * @return string |
| 139 | 139 | */ |
| 140 | - public function getAuthorizationURL($apiSettings = '', $callbackURL = self::DEFAULT_CALLBACK, $responseType = 'code', $testMode = false){ |
|
| 141 | - $allowedTypes = ['token', 'code']; |
|
| 140 | + public function getAuthorizationURL($apiSettings = '', $callbackURL = self::DEFAULT_CALLBACK, $responseType = 'code', $testMode = false) { |
|
| 141 | + $allowedTypes = [ 'token', 'code' ]; |
|
| 142 | 142 | $requestParameters = [ |
| 143 | 143 | 'client_id' => $this->applicationID, |
| 144 | 144 | 'scope' => $apiSettings, |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | 'response_type' => (in_array($responseType, $allowedTypes)) ? $responseType : 'code' |
| 147 | 147 | ]; |
| 148 | 148 | |
| 149 | - if($testMode) $requestParameters['test_mode'] = 1; |
|
| 149 | + if ($testMode) $requestParameters[ 'test_mode' ] = 1; |
|
| 150 | 150 | |
| 151 | 151 | return $this->createURL(self::AUTHORIZATION_URL, $requestParameters); |
| 152 | 152 | } |
@@ -158,8 +158,8 @@ discard block |
||
| 158 | 158 | * @return mixed |
| 159 | 159 | * @throws VKException |
| 160 | 160 | */ |
| 161 | - public function getAccessToken($resultCode, $callbackURL = self::DEFAULT_CALLBACK){ |
|
| 162 | - if(!is_null($this->accessToken) && $this->authorizationStatus) { |
|
| 161 | + public function getAccessToken($resultCode, $callbackURL = self::DEFAULT_CALLBACK) { |
|
| 162 | + if (!is_null($this->accessToken) && $this->authorizationStatus) { |
|
| 163 | 163 | throw new VKException('Already Authorized!', 1); |
| 164 | 164 | } |
| 165 | 165 | |
@@ -173,16 +173,16 @@ discard block |
||
| 173 | 173 | $apiResponse = json_decode($this->performRequest($this->createURL(self::ACCESS_TOKEN_URL, $requestParameters)), true); |
| 174 | 174 | |
| 175 | 175 | try { |
| 176 | - if(isset($apiResponse['error'])) { |
|
| 177 | - throw new VKException($apiResponse['error'] . (!isset($apiResponse['error_description']) ?: ': ' . $apiResponse['error_description']), '0'); |
|
| 176 | + if (isset($apiResponse[ 'error' ])) { |
|
| 177 | + throw new VKException($apiResponse[ 'error' ].(!isset($apiResponse[ 'error_description' ]) ?: ': '.$apiResponse[ 'error_description' ]), '0'); |
|
| 178 | 178 | } else { |
| 179 | 179 | $this->authorizationStatus = true; |
| 180 | - $this->accessToken = $apiResponse['access_token']; |
|
| 180 | + $this->accessToken = $apiResponse[ 'access_token' ]; |
|
| 181 | 181 | return $apiResponse; |
| 182 | 182 | } |
| 183 | - } catch (VKException $ex){ |
|
| 183 | + } catch (VKException $ex) { |
|
| 184 | 184 | echo $ex->getMessage(); |
| 185 | - return []; |
|
| 185 | + return [ ]; |
|
| 186 | 186 | } |
| 187 | 187 | } |
| 188 | 188 | |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | * Returns User Authorization Status |
| 191 | 191 | * @return bool |
| 192 | 192 | */ |
| 193 | - public function isAuthorized(){ |
|
| 193 | + public function isAuthorized() { |
|
| 194 | 194 | return !is_null($this->accessToken); |
| 195 | 195 | } |
| 196 | 196 | |
@@ -203,32 +203,32 @@ discard block |
||
| 203 | 203 | * @param string $requestMethod |
| 204 | 204 | * @return mixed |
| 205 | 205 | */ |
| 206 | - public function apiQuery($apiMethod, $requestParameters = [], $resultType = 'array', $requestMethod = 'get'){ |
|
| 207 | - $requestParameters['timestamp'] = time(); |
|
| 208 | - $requestParameters['api_id'] = $this->applicationID; |
|
| 209 | - $requestParameters['random'] = rand(0, 10000); |
|
| 206 | + public function apiQuery($apiMethod, $requestParameters = [ ], $resultType = 'array', $requestMethod = 'get') { |
|
| 207 | + $requestParameters[ 'timestamp' ] = time(); |
|
| 208 | + $requestParameters[ 'api_id' ] = $this->applicationID; |
|
| 209 | + $requestParameters[ 'random' ] = rand(0, 10000); |
|
| 210 | 210 | |
| 211 | - if(!array_key_exists('access_token', $requestParameters) && !is_null($this->accessToken)) { |
|
| 212 | - $requestParameters['access_token'] = $this->accessToken; |
|
| 211 | + if (!array_key_exists('access_token', $requestParameters) && !is_null($this->accessToken)) { |
|
| 212 | + $requestParameters[ 'access_token' ] = $this->accessToken; |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | - if(!array_key_exists('v', $requestParameters) && !is_null($this->APIVersion)) { |
|
| 216 | - $requestParameters['v'] = $this->APIVersion; |
|
| 215 | + if (!array_key_exists('v', $requestParameters) && !is_null($this->APIVersion)) { |
|
| 216 | + $requestParameters[ 'v' ] = $this->APIVersion; |
|
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | ksort($requestParameters); |
| 220 | 220 | |
| 221 | 221 | $parametersSignature = ''; |
| 222 | - foreach($requestParameters as $pKey=>$pValue){ |
|
| 223 | - if(is_array($pValue)) |
|
| 222 | + foreach ($requestParameters as $pKey=>$pValue) { |
|
| 223 | + if (is_array($pValue)) |
|
| 224 | 224 | $pValue = implode(', ', $pValue); |
| 225 | - $parametersSignature .= $pKey . '=' . $pValue; |
|
| 225 | + $parametersSignature .= $pKey.'='.$pValue; |
|
| 226 | 226 | } |
| 227 | 227 | $parametersSignature .= $this->APISecret; |
| 228 | 228 | |
| 229 | - $requestParameters['sig'] = md5($parametersSignature); |
|
| 229 | + $requestParameters[ 'sig' ] = md5($parametersSignature); |
|
| 230 | 230 | |
| 231 | - if($apiMethod == 'execute' || $requestMethod == 'post'){ |
|
| 231 | + if ($apiMethod == 'execute' || $requestMethod == 'post') { |
|
| 232 | 232 | $apiResponse = $this->performRequest($this->getAPIUrl($apiMethod, $resultType == 'array' ? 'json' : $resultType), "POST", $requestParameters); |
| 233 | 233 | } else { |
| 234 | 234 | $apiResponse = $this->performRequest($this->createURL($this->getAPIUrl($apiMethod, $resultType == 'array' ? 'json' : $resultType), $requestParameters)); |
@@ -236,13 +236,13 @@ discard block |
||
| 236 | 236 | |
| 237 | 237 | try { |
| 238 | 238 | $decodedJSON = json_decode($apiResponse, true); |
| 239 | - if(isset($decodedJSON['error'])) |
|
| 240 | - throw new VKException($decodedJSON['error']['error_msg'], $decodedJSON['error']['error_code'], $decodedJSON['error']['request_params']); |
|
| 239 | + if (isset($decodedJSON[ 'error' ])) |
|
| 240 | + throw new VKException($decodedJSON[ 'error' ][ 'error_msg' ], $decodedJSON[ 'error' ][ 'error_code' ], $decodedJSON[ 'error' ][ 'request_params' ]); |
|
| 241 | 241 | |
| 242 | 242 | return $resultType == 'array' ? $decodedJSON : $apiResponse; |
| 243 | - } catch(VKException $ex){ |
|
| 243 | + } catch (VKException $ex) { |
|
| 244 | 244 | echo $ex->getMessage(); |
| 245 | - return []; |
|
| 245 | + return [ ]; |
|
| 246 | 246 | } |
| 247 | 247 | } |
| 248 | 248 | |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | * Set Permissions Mask |
| 251 | 251 | * @param int $permMask |
| 252 | 252 | */ |
| 253 | - public function setPermissionsMask($permMask){ |
|
| 253 | + public function setPermissionsMask($permMask) { |
|
| 254 | 254 | $this->permissionsMask = $permMask; |
| 255 | 255 | } |
| 256 | 256 | |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | * Get Permissions Mask |
| 259 | 259 | * @return int |
| 260 | 260 | */ |
| 261 | - public function getPermissionsMask(){ |
|
| 261 | + public function getPermissionsMask() { |
|
| 262 | 262 | return $this->permissionsMask; |
| 263 | 263 | } |
| 264 | 264 | |
@@ -268,8 +268,8 @@ discard block |
||
| 268 | 268 | * @param array $parametersArray |
| 269 | 269 | * @return string |
| 270 | 270 | */ |
| 271 | - private function createURL($urlString, $parametersArray){ |
|
| 272 | - $urlString .= '?' . http_build_query($parametersArray); |
|
| 271 | + private function createURL($urlString, $parametersArray) { |
|
| 272 | + $urlString .= '?'.http_build_query($parametersArray); |
|
| 273 | 273 | return $urlString; |
| 274 | 274 | } |
| 275 | 275 | |
@@ -280,9 +280,9 @@ discard block |
||
| 280 | 280 | * @param array $postFields |
| 281 | 281 | * @return string |
| 282 | 282 | */ |
| 283 | - private function performRequest($requestURL, $requestMethod = 'GET', $postFields = []){ |
|
| 283 | + private function performRequest($requestURL, $requestMethod = 'GET', $postFields = [ ]) { |
|
| 284 | 284 | curl_setopt_array($this->curlObject, [ |
| 285 | - CURLOPT_USERAGENT => 'FreedomCore/' . self::PACKAGE_VERSION . ' VK OAuth Client', |
|
| 285 | + CURLOPT_USERAGENT => 'FreedomCore/'.self::PACKAGE_VERSION.' VK OAuth Client', |
|
| 286 | 286 | CURLOPT_RETURNTRANSFER => true, |
| 287 | 287 | CURLOPT_SSL_VERIFYPEER => false, |
| 288 | 288 | CURLOPT_POST => ($requestMethod == 'POST'), |
@@ -313,14 +313,14 @@ discard block |
||
| 313 | 313 | |
| 314 | 314 | $Message .= '<tr><td width="10%"><strong>Error Code:</strong></td> <td>'.$code.'</td></tr>'; |
| 315 | 315 | $APIError = $this->codeToErrorText($code); |
| 316 | - $Message .= '<tr><td width="10%"><strong>API Message:</strong></td> <td>'.$APIError['title'].' <span style="color: gray;">('.$APIError['description'].')</span></td></tr>'; |
|
| 316 | + $Message .= '<tr><td width="10%"><strong>API Message:</strong></td> <td>'.$APIError[ 'title' ].' <span style="color: gray;">('.$APIError[ 'description' ].')</span></td></tr>'; |
|
| 317 | 317 | $Message .= '<tr><td width="10%"><strong>Error Message:</strong></td> <td>'.$message.'</td></tr>'; |
| 318 | - if($parameters != null && is_array($parameters)){ |
|
| 318 | + if ($parameters != null && is_array($parameters)) { |
|
| 319 | 319 | $Message .= '<tr><td width="10%"><strong>Request Parameters:</strong></td> <td>'; |
| 320 | 320 | |
| 321 | 321 | $Message .= '<table width="15%">'; |
| 322 | - foreach($parameters as $parameter){ |
|
| 323 | - $Message .= "<tr><td><strong>".$parameter['key']."</strong></td><td width='15%'>=></td><td>".$parameter['value']."</td></tr>"; |
|
| 322 | + foreach ($parameters as $parameter) { |
|
| 323 | + $Message .= "<tr><td><strong>".$parameter[ 'key' ]."</strong></td><td width='15%'>=></td><td>".$parameter[ 'value' ]."</td></tr>"; |
|
| 324 | 324 | } |
| 325 | 325 | $Message .= '</table>'; |
| 326 | 326 | $Message .= '</td></tr>'; |
@@ -335,44 +335,44 @@ discard block |
||
| 335 | 335 | * @param $Code |
| 336 | 336 | * @return mixed |
| 337 | 337 | */ |
| 338 | - private function codeToErrorText($Code){ |
|
| 338 | + private function codeToErrorText($Code) { |
|
| 339 | 339 | $errorsData = [ |
| 340 | - 1 => ['title' => 'Unknown error occurred', 'description' => 'Try again later.'], |
|
| 341 | - 2 => ['title' => 'Application is disabled. Enable your application or use test mode ', 'description' => 'You need to switch on the app in Settings (https://vk.com/editapp?id={Your API_ID} or use the test mode (test_mode=1).'], |
|
| 342 | - 3 => ['title' => 'Unknown method passed ', 'description' => 'Check the method name: <a href="http://vk.com/dev/methods" target="_blank">http://vk.com/dev/methods</a> '], |
|
| 343 | - 4 => ['title' => 'Incorrect signature ', 'description' => 'Check if the signature has been formed correctly: <a href="https://vk.com/dev/api_nohttps" target="_blank"></a>'], |
|
| 344 | - 5 => ['title' => 'User authorization failed ', 'description' => 'Make sure that you use a correct authorization type. To work with the methods without a secureprefix you need to authorize a user with one of these ways: http://vk.com/dev/auth_sites, http://vk.com/dev/auth_mobile.'], |
|
| 345 | - 6 => ['title' => 'Too many requests per second ', 'description' => 'Decrease the request frequency or use the execute method. More details on frequency limits here: <a href="http://vk.com/dev/api_requests" target="_blank">http://vk.com/dev/api_requests</a>'], |
|
| 346 | - 7 => ['title' => 'Permission to perform this action is denied ', 'description' => 'Make sure that your have received required permissions during the authorization. You can do it with the account.getAppPermissions method.'], |
|
| 347 | - 8 => ['title' => 'Invalid request ', 'description' => 'Check the request syntax and used parameters list (it can be found on a method description page) '], |
|
| 348 | - 9 => ['title' => 'Flood control ', 'description' => 'You need to decrease the count of identical requests. For more efficient work you may use execute or JSONP.'], |
|
| 349 | - 10 => ['title' => 'Internal server error', 'description' => 'Try again later.'], |
|
| 350 | - 11 => ['title' => 'In test mode application should be disabled or user should be authorized', 'description' => 'Switch the app off in Settings: https://vk.com/editapp?id={Your API_ID}.'], |
|
| 351 | - 14 => ['title' => 'Captcha needed ', 'description' => 'Work with this error is explained in detail on the <a href="https://vk.com/dev/need_confirmation" target="_blank">separate page</a>'], |
|
| 352 | - 15 => ['title' => 'Access denied ', 'description' => 'Make sure that you use correct identifiers and the content is available for the user in the full version of the site.'], |
|
| 353 | - 16 => ['title' => 'HTTP authorization failed', 'description' => 'To avoid this error check if a user has the \'Use secure connection\' option enabled with the account.getInfo method.'], |
|
| 354 | - 17 => ['title' => 'Validation required ', 'description' => 'Make sure that you don\'t use a token received with http://vk.com/dev/auth_mobile for a request from the server. It\'s restricted. The validation process is described on the <a href="https://vk.com/dev/need_confirmation" target="_blank">separate page</a>.'], |
|
| 355 | - 20 => ['title' => 'Permission to perform this action is denied for non-standalone applications ', 'description' => 'If you see this error despite your app has the Standalone type, make sure that you use redirect_uri=https://oauth.vk.com/blank.html. Details here: http://vk.com/dev/auth_mobile.'], |
|
| 356 | - 21 => ['title' => 'Permission to perform this action is allowed only for Standalone and OpenAPI applications', 'description' => ''], |
|
| 357 | - 23 => ['title' => 'This method was disabled ', 'description' => 'All the methods available now are listed here: <a href="http://vk.com/dev/methods" target="_blank">http://vk.com/dev/methods</a>'], |
|
| 358 | - 24 => ['title' => 'Confirmation required ', 'description' => 'Confirmation process is described on the <a href="https://vk.com/dev/need_confirmation" target="_blank">separate page</a>'], |
|
| 359 | - 100 => ['title' => 'One of the parameters specified was missing or invalid ', 'description' => 'Check the required parameters list and their format on a method description page.'], |
|
| 360 | - 101 => ['title' => 'Invalid application API ID ', 'description' => 'Find the app in the administrated list in settings: <a href="http://vk.com/apps?act=settings" target="_blank">http://vk.com/apps?act=settings</a> And set the correct API_ID in the request.'], |
|
| 361 | - 103 => ['title' => 'Out of limits', 'description' => 'Out of limits'], |
|
| 362 | - 104 => ['title' => 'Not found', 'description' => 'Not found'], |
|
| 363 | - 113 => ['title' => 'Invalid user id ', 'description' => 'Make sure that you use a correct id. You can get an id using a screen name with the utils.resolveScreenName method'], |
|
| 364 | - 150 => ['title' => 'Invalid timestamp ', 'description' => 'You may get a correct value with the utils.getServerTime method.'], |
|
| 365 | - 200 => ['title' => 'Access to album denied ', 'description' => 'Make sure you use correct ids (owner_id is always positive for users, negative for communities) and the current user has access to the requested content in the full version of the site.'], |
|
| 366 | - 201 => ['title' => 'Access to audio denied ', 'description' => 'Make sure you use correct ids (owner_id is always positive for users, negative for communities) and the current user has access to the requested content in the full version of the site.'], |
|
| 367 | - 203 => ['title' => 'Access to group denied ', 'description' => 'Make sure that the current user is a member or admin of the community (for closed and private groups and events).'], |
|
| 368 | - 300 => ['title' => 'This album is full ', 'description' => 'You need to delete the odd objects from the album or use another album.'], |
|
| 369 | - 500 => ['title' => 'Permission denied. You must enable votes processing in application settings', 'description' => 'Check the app settings: http://vk.com/editapp?id={Your API_ID}§ion=payments'], |
|
| 370 | - 600 => ['title' => 'Permission denied. You have no access to operations specified with given object(s)', 'description' => ''], |
|
| 371 | - 603 => ['title' => 'Some ads error occurred', 'description' => ''], |
|
| 372 | - 1260 => ['title' => 'Invalid screen name', 'description' => 'This screen name is already in use or invalid'], |
|
| 340 | + 1 => [ 'title' => 'Unknown error occurred', 'description' => 'Try again later.' ], |
|
| 341 | + 2 => [ 'title' => 'Application is disabled. Enable your application or use test mode ', 'description' => 'You need to switch on the app in Settings (https://vk.com/editapp?id={Your API_ID} or use the test mode (test_mode=1).' ], |
|
| 342 | + 3 => [ 'title' => 'Unknown method passed ', 'description' => 'Check the method name: <a href="http://vk.com/dev/methods" target="_blank">http://vk.com/dev/methods</a> ' ], |
|
| 343 | + 4 => [ 'title' => 'Incorrect signature ', 'description' => 'Check if the signature has been formed correctly: <a href="https://vk.com/dev/api_nohttps" target="_blank"></a>' ], |
|
| 344 | + 5 => [ 'title' => 'User authorization failed ', 'description' => 'Make sure that you use a correct authorization type. To work with the methods without a secureprefix you need to authorize a user with one of these ways: http://vk.com/dev/auth_sites, http://vk.com/dev/auth_mobile.' ], |
|
| 345 | + 6 => [ 'title' => 'Too many requests per second ', 'description' => 'Decrease the request frequency or use the execute method. More details on frequency limits here: <a href="http://vk.com/dev/api_requests" target="_blank">http://vk.com/dev/api_requests</a>' ], |
|
| 346 | + 7 => [ 'title' => 'Permission to perform this action is denied ', 'description' => 'Make sure that your have received required permissions during the authorization. You can do it with the account.getAppPermissions method.' ], |
|
| 347 | + 8 => [ 'title' => 'Invalid request ', 'description' => 'Check the request syntax and used parameters list (it can be found on a method description page) ' ], |
|
| 348 | + 9 => [ 'title' => 'Flood control ', 'description' => 'You need to decrease the count of identical requests. For more efficient work you may use execute or JSONP.' ], |
|
| 349 | + 10 => [ 'title' => 'Internal server error', 'description' => 'Try again later.' ], |
|
| 350 | + 11 => [ 'title' => 'In test mode application should be disabled or user should be authorized', 'description' => 'Switch the app off in Settings: https://vk.com/editapp?id={Your API_ID}.' ], |
|
| 351 | + 14 => [ 'title' => 'Captcha needed ', 'description' => 'Work with this error is explained in detail on the <a href="https://vk.com/dev/need_confirmation" target="_blank">separate page</a>' ], |
|
| 352 | + 15 => [ 'title' => 'Access denied ', 'description' => 'Make sure that you use correct identifiers and the content is available for the user in the full version of the site.' ], |
|
| 353 | + 16 => [ 'title' => 'HTTP authorization failed', 'description' => 'To avoid this error check if a user has the \'Use secure connection\' option enabled with the account.getInfo method.' ], |
|
| 354 | + 17 => [ 'title' => 'Validation required ', 'description' => 'Make sure that you don\'t use a token received with http://vk.com/dev/auth_mobile for a request from the server. It\'s restricted. The validation process is described on the <a href="https://vk.com/dev/need_confirmation" target="_blank">separate page</a>.' ], |
|
| 355 | + 20 => [ 'title' => 'Permission to perform this action is denied for non-standalone applications ', 'description' => 'If you see this error despite your app has the Standalone type, make sure that you use redirect_uri=https://oauth.vk.com/blank.html. Details here: http://vk.com/dev/auth_mobile.' ], |
|
| 356 | + 21 => [ 'title' => 'Permission to perform this action is allowed only for Standalone and OpenAPI applications', 'description' => '' ], |
|
| 357 | + 23 => [ 'title' => 'This method was disabled ', 'description' => 'All the methods available now are listed here: <a href="http://vk.com/dev/methods" target="_blank">http://vk.com/dev/methods</a>' ], |
|
| 358 | + 24 => [ 'title' => 'Confirmation required ', 'description' => 'Confirmation process is described on the <a href="https://vk.com/dev/need_confirmation" target="_blank">separate page</a>' ], |
|
| 359 | + 100 => [ 'title' => 'One of the parameters specified was missing or invalid ', 'description' => 'Check the required parameters list and their format on a method description page.' ], |
|
| 360 | + 101 => [ 'title' => 'Invalid application API ID ', 'description' => 'Find the app in the administrated list in settings: <a href="http://vk.com/apps?act=settings" target="_blank">http://vk.com/apps?act=settings</a> And set the correct API_ID in the request.' ], |
|
| 361 | + 103 => [ 'title' => 'Out of limits', 'description' => 'Out of limits' ], |
|
| 362 | + 104 => [ 'title' => 'Not found', 'description' => 'Not found' ], |
|
| 363 | + 113 => [ 'title' => 'Invalid user id ', 'description' => 'Make sure that you use a correct id. You can get an id using a screen name with the utils.resolveScreenName method' ], |
|
| 364 | + 150 => [ 'title' => 'Invalid timestamp ', 'description' => 'You may get a correct value with the utils.getServerTime method.' ], |
|
| 365 | + 200 => [ 'title' => 'Access to album denied ', 'description' => 'Make sure you use correct ids (owner_id is always positive for users, negative for communities) and the current user has access to the requested content in the full version of the site.' ], |
|
| 366 | + 201 => [ 'title' => 'Access to audio denied ', 'description' => 'Make sure you use correct ids (owner_id is always positive for users, negative for communities) and the current user has access to the requested content in the full version of the site.' ], |
|
| 367 | + 203 => [ 'title' => 'Access to group denied ', 'description' => 'Make sure that the current user is a member or admin of the community (for closed and private groups and events).' ], |
|
| 368 | + 300 => [ 'title' => 'This album is full ', 'description' => 'You need to delete the odd objects from the album or use another album.' ], |
|
| 369 | + 500 => [ 'title' => 'Permission denied. You must enable votes processing in application settings', 'description' => 'Check the app settings: http://vk.com/editapp?id={Your API_ID}§ion=payments' ], |
|
| 370 | + 600 => [ 'title' => 'Permission denied. You have no access to operations specified with given object(s)', 'description' => '' ], |
|
| 371 | + 603 => [ 'title' => 'Some ads error occurred', 'description' => '' ], |
|
| 372 | + 1260 => [ 'title' => 'Invalid screen name', 'description' => 'This screen name is already in use or invalid' ], |
|
| 373 | 373 | ]; |
| 374 | 374 | |
| 375 | - return (!array_key_exists($Code, $errorsData)) ? $errorsData[1] : $errorsData[$Code]; |
|
| 375 | + return (!array_key_exists($Code, $errorsData)) ? $errorsData[ 1 ] : $errorsData[ $Code ]; |
|
| 376 | 376 | } |
| 377 | 377 | |
| 378 | 378 | } |
| 379 | 379 | \ No newline at end of file |
@@ -146,7 +146,9 @@ discard block |
||
| 146 | 146 | 'response_type' => (in_array($responseType, $allowedTypes)) ? $responseType : 'code' |
| 147 | 147 | ]; |
| 148 | 148 | |
| 149 | - if($testMode) $requestParameters['test_mode'] = 1; |
|
| 149 | + if($testMode) { |
|
| 150 | + $requestParameters['test_mode'] = 1; |
|
| 151 | + } |
|
| 150 | 152 | |
| 151 | 153 | return $this->createURL(self::AUTHORIZATION_URL, $requestParameters); |
| 152 | 154 | } |
@@ -220,8 +222,9 @@ discard block |
||
| 220 | 222 | |
| 221 | 223 | $parametersSignature = ''; |
| 222 | 224 | foreach($requestParameters as $pKey=>$pValue){ |
| 223 | - if(is_array($pValue)) |
|
| 224 | - $pValue = implode(', ', $pValue); |
|
| 225 | + if(is_array($pValue)) { |
|
| 226 | + $pValue = implode(', ', $pValue); |
|
| 227 | + } |
|
| 225 | 228 | $parametersSignature .= $pKey . '=' . $pValue; |
| 226 | 229 | } |
| 227 | 230 | $parametersSignature .= $this->APISecret; |
@@ -236,8 +239,9 @@ discard block |
||
| 236 | 239 | |
| 237 | 240 | try { |
| 238 | 241 | $decodedJSON = json_decode($apiResponse, true); |
| 239 | - if(isset($decodedJSON['error'])) |
|
| 240 | - throw new VKException($decodedJSON['error']['error_msg'], $decodedJSON['error']['error_code'], $decodedJSON['error']['request_params']); |
|
| 242 | + if(isset($decodedJSON['error'])) { |
|
| 243 | + throw new VKException($decodedJSON['error']['error_msg'], $decodedJSON['error']['error_code'], $decodedJSON['error']['request_params']); |
|
| 244 | + } |
|
| 241 | 245 | |
| 242 | 246 | return $resultType == 'array' ? $decodedJSON : $apiResponse; |
| 243 | 247 | } catch(VKException $ex){ |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | * VKDocuments constructor. |
| 18 | 18 | * @param VKBase $vkObject |
| 19 | 19 | */ |
| 20 | - public function __construct(VKBase $vkObject){ |
|
| 20 | + public function __construct(VKBase $vkObject) { |
|
| 21 | 21 | parent::__construct($vkObject); |
| 22 | 22 | } |
| 23 | 23 | |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | * @return mixed |
| 30 | 30 | * @throws VKException |
| 31 | 31 | */ |
| 32 | - public function get($ownerID, $setCount = 10, $setOffset = 0){ |
|
| 32 | + public function get($ownerID, $setCount = 10, $setOffset = 0) { |
|
| 33 | 33 | parent::isAllowed(); |
| 34 | 34 | $requestParameters = [ |
| 35 | 35 | 'owner_id' => $ownerID, |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | * @return mixed |
| 46 | 46 | * @throws VKException |
| 47 | 47 | */ |
| 48 | - public function getById($documentIDorArray){ |
|
| 48 | + public function getById($documentIDorArray) { |
|
| 49 | 49 | parent::isAllowed(); |
| 50 | 50 | $requestParameters = [ |
| 51 | 51 | 'docs' => (is_array($documentIDorArray)) ? implode(',', $documentIDorArray) : $documentIDorArray |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | * @param $communityID |
| 60 | 60 | * @return mixed |
| 61 | 61 | */ |
| 62 | - public function getUploadServer($communityID){ |
|
| 62 | + public function getUploadServer($communityID) { |
|
| 63 | 63 | parent::isAllowed(); |
| 64 | 64 | $requestParameters = [ |
| 65 | 65 | 'group_id' => $communityID |
@@ -21,13 +21,13 @@ discard block |
||
| 21 | 21 | /** |
| 22 | 22 | * Default Fields For Selection |
| 23 | 23 | */ |
| 24 | - const defaultFields = ['description', 'members_count', 'status', 'contacts']; |
|
| 24 | + const defaultFields = [ 'description', 'members_count', 'status', 'contacts' ]; |
|
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | 27 | * VKGroups constructor. |
| 28 | 28 | * @param VKBase $vkObject |
| 29 | 29 | */ |
| 30 | - public function __construct(VKBase $vkObject){ |
|
| 30 | + public function __construct(VKBase $vkObject) { |
|
| 31 | 31 | parent::__construct($vkObject); |
| 32 | 32 | parent::isAllowed($this->requiredPermission); |
| 33 | 33 | } |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | * @param int $isExtended |
| 40 | 40 | * @return mixed |
| 41 | 41 | */ |
| 42 | - public function isMember($groupID, $userID, $isExtended = 0){ |
|
| 42 | + public function isMember($groupID, $userID, $isExtended = 0) { |
|
| 43 | 43 | $requestParameters = [ |
| 44 | 44 | 'group_id' => $groupID, |
| 45 | 45 | 'user_id' => $userID, |
@@ -55,12 +55,12 @@ discard block |
||
| 55 | 55 | * @param array $requestFields |
| 56 | 56 | * @return mixed |
| 57 | 57 | */ |
| 58 | - public function getById($groupID, $requestFields = self::defaultFields){ |
|
| 58 | + public function getById($groupID, $requestFields = self::defaultFields) { |
|
| 59 | 59 | $requestParameters = [ |
| 60 | 60 | 'fields' => $this->getAllowedFields($requestFields) |
| 61 | 61 | ]; |
| 62 | - if(is_array($groupID)) $requestParameters['group_ids'] = implode(',', $groupID); |
|
| 63 | - else $requestParameters['group_id'] = $groupID; |
|
| 62 | + if (is_array($groupID)) $requestParameters[ 'group_ids' ] = implode(',', $groupID); |
|
| 63 | + else $requestParameters[ 'group_id' ] = $groupID; |
|
| 64 | 64 | |
| 65 | 65 | return parent::executeQuery(__FUNCTION__, $requestParameters); |
| 66 | 66 | } |
@@ -73,14 +73,14 @@ discard block |
||
| 73 | 73 | * @param array $requestFields |
| 74 | 74 | * @return mixed |
| 75 | 75 | */ |
| 76 | - public function get($userID, $isExtended = 0, $setFilter = null, $requestFields = self::defaultFields){ |
|
| 77 | - $allowedFilterTypes = ['admin', 'editor', 'moder', 'groups', 'publics', 'events']; |
|
| 76 | + public function get($userID, $isExtended = 0, $setFilter = null, $requestFields = self::defaultFields) { |
|
| 77 | + $allowedFilterTypes = [ 'admin', 'editor', 'moder', 'groups', 'publics', 'events' ]; |
|
| 78 | 78 | $requestParameters = [ |
| 79 | 79 | 'user_id' => $userID, |
| 80 | 80 | 'extended' => ($isExtended > 1 || $isExtended < 0) ? 0 : $isExtended, |
| 81 | 81 | 'fields' => $this->getAllowedFields($requestFields) |
| 82 | 82 | ]; |
| 83 | - if($setFilter != null && in_array($setFilter, $allowedFilterTypes)){ $requestParameters['filter'] = $setFilter; } |
|
| 83 | + if ($setFilter != null && in_array($setFilter, $allowedFilterTypes)) { $requestParameters[ 'filter' ] = $setFilter; } |
|
| 84 | 84 | |
| 85 | 85 | return parent::executeQuery(__FUNCTION__, $requestParameters); |
| 86 | 86 | } |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | * @param array $requestFields |
| 92 | 92 | * @return mixed |
| 93 | 93 | */ |
| 94 | - public function getMembers($groupID, $requestFields = VKUsers::standardFields){ |
|
| 94 | + public function getMembers($groupID, $requestFields = VKUsers::standardFields) { |
|
| 95 | 95 | $requestParameters = [ |
| 96 | 96 | 'group_id' => $groupID, |
| 97 | 97 | 'fields' => $requestFields |
@@ -106,9 +106,9 @@ discard block |
||
| 106 | 106 | * @param null $ifMeeting |
| 107 | 107 | * @return mixed |
| 108 | 108 | */ |
| 109 | - public function join($groupID, $ifMeeting = null){ |
|
| 110 | - $requestParameters['group_id'] = $groupID; |
|
| 111 | - if($ifMeeting != null){ if($ifMeeting == 1 || $ifMeeting == 0) { $requestParameters['not_sure'] = $ifMeeting; } } |
|
| 109 | + public function join($groupID, $ifMeeting = null) { |
|
| 110 | + $requestParameters[ 'group_id' ] = $groupID; |
|
| 111 | + if ($ifMeeting != null) { if ($ifMeeting == 1 || $ifMeeting == 0) { $requestParameters[ 'not_sure' ] = $ifMeeting; } } |
|
| 112 | 112 | |
| 113 | 113 | return parent::executeQuery(__FUNCTION__, $requestParameters); |
| 114 | 114 | } |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | * @return mixed |
| 120 | 120 | */ |
| 121 | 121 | public function leave($groupID) { |
| 122 | - $requestParameters['group_id'] = $groupID; |
|
| 122 | + $requestParameters[ 'group_id' ] = $groupID; |
|
| 123 | 123 | |
| 124 | 124 | return parent::executeQuery(__FUNCTION__, $requestParameters); |
| 125 | 125 | } |
@@ -131,8 +131,8 @@ discard block |
||
| 131 | 131 | * @return mixed |
| 132 | 132 | */ |
| 133 | 133 | public function search($searchQuery, $groupType = null) { |
| 134 | - $requestParameters['q'] = $searchQuery; |
|
| 135 | - if($groupType != null && in_array($groupType, ['group', 'page', 'event'])) { $requestParameters['type'] = $groupType; } |
|
| 134 | + $requestParameters[ 'q' ] = $searchQuery; |
|
| 135 | + if ($groupType != null && in_array($groupType, [ 'group', 'page', 'event' ])) { $requestParameters[ 'type' ] = $groupType; } |
|
| 136 | 136 | |
| 137 | 137 | return parent::executeQuery(__FUNCTION__, $requestParameters); |
| 138 | 138 | } |
@@ -142,8 +142,8 @@ discard block |
||
| 142 | 142 | * @param int $isExtended |
| 143 | 143 | * @return mixed |
| 144 | 144 | */ |
| 145 | - public function getInvites($isExtended = 0){ |
|
| 146 | - $requestParameters['extended'] = ($isExtended > 1 || $isExtended < 0) ? 0 : $isExtended; |
|
| 145 | + public function getInvites($isExtended = 0) { |
|
| 146 | + $requestParameters[ 'extended' ] = ($isExtended > 1 || $isExtended < 0) ? 0 : $isExtended; |
|
| 147 | 147 | return parent::executeQuery(__FUNCTION__, $requestParameters); |
| 148 | 148 | } |
| 149 | 149 | |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | * @param array $requestFields |
| 154 | 154 | * @return mixed |
| 155 | 155 | */ |
| 156 | - public function getInvitedUsers($groupID, $requestFields = VKUsers::standardFields){ |
|
| 156 | + public function getInvitedUsers($groupID, $requestFields = VKUsers::standardFields) { |
|
| 157 | 157 | $requestParameters = [ |
| 158 | 158 | 'group_id' => $groupID, |
| 159 | 159 | 'fields ' => $requestFields |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | * @param int $endDateTimeStamp - Unix Time |
| 171 | 171 | * @param int $commentVisible - Show Comment To User (1 - Yes | 0 - No) |
| 172 | 172 | */ |
| 173 | - public function banUser($groupID, $userID, $banReason = 0, $banComment = '', $endDateTimeStamp = null, $commentVisible = 1){ |
|
| 173 | + public function banUser($groupID, $userID, $banReason = 0, $banComment = '', $endDateTimeStamp = null, $commentVisible = 1) { |
|
| 174 | 174 | $requestParameters = [ |
| 175 | 175 | 'group_id' => $groupID, |
| 176 | 176 | 'user_id' => $userID, |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | * @param int $userID |
| 190 | 190 | * @return mixed |
| 191 | 191 | */ |
| 192 | - public function unbanUser($groupID, $userID){ |
|
| 192 | + public function unbanUser($groupID, $userID) { |
|
| 193 | 193 | $requestParameters = [ |
| 194 | 194 | 'group_id' => $groupID, |
| 195 | 195 | 'user_id' => $userID |
@@ -202,8 +202,8 @@ discard block |
||
| 202 | 202 | * @param int $groupID |
| 203 | 203 | * @return mixed |
| 204 | 204 | */ |
| 205 | - public function getBanned($groupID){ |
|
| 206 | - return parent::executeQuery(__FUNCTION__, ['group_id' => $groupID]); |
|
| 205 | + public function getBanned($groupID) { |
|
| 206 | + return parent::executeQuery(__FUNCTION__, [ 'group_id' => $groupID ]); |
|
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | /** |
@@ -214,14 +214,14 @@ discard block |
||
| 214 | 214 | * @param int $subType |
| 215 | 215 | * @return mixed |
| 216 | 216 | */ |
| 217 | - public function create($groupTitle, $groupDescription, $groupType = 'group', $subType = null){ |
|
| 218 | - $allowedGroupTypes = ['group', 'event', 'public']; |
|
| 217 | + public function create($groupTitle, $groupDescription, $groupType = 'group', $subType = null) { |
|
| 218 | + $allowedGroupTypes = [ 'group', 'event', 'public' ]; |
|
| 219 | 219 | $requestParameters = [ |
| 220 | 220 | 'title' => $groupTitle, |
| 221 | 221 | 'type' => (in_array($groupType, $allowedGroupTypes)) ? $groupType : 'group' |
| 222 | 222 | ]; |
| 223 | - if($groupType != 'public') { $requestParameters['description'] = $groupDescription; } |
|
| 224 | - if($subType != null) { $requestParameters['subtype'] = ($subType > 4 || $subType < 1) ? 2 : $subType;} |
|
| 223 | + if ($groupType != 'public') { $requestParameters[ 'description' ] = $groupDescription; } |
|
| 224 | + if ($subType != null) { $requestParameters[ 'subtype' ] = ($subType > 4 || $subType < 1) ? 2 : $subType; } |
|
| 225 | 225 | |
| 226 | 226 | return parent::executeQuery(__FUNCTION__, $requestParameters); |
| 227 | 227 | } |
@@ -255,8 +255,8 @@ discard block |
||
| 255 | 255 | * @param int $groupID |
| 256 | 256 | * @return mixed |
| 257 | 257 | */ |
| 258 | - public function getSettings($groupID){ |
|
| 259 | - return parent::executeQuery(__FUNCTION__, ['group_id' => $groupID]); |
|
| 258 | + public function getSettings($groupID) { |
|
| 259 | + return parent::executeQuery(__FUNCTION__, [ 'group_id' => $groupID ]); |
|
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | /** |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | * @return array |
| 268 | 268 | */ |
| 269 | 269 | public function getRequests($groupID, $requestFields = null, $setCount = 20) { |
| 270 | - if($requestFields == null) |
|
| 270 | + if ($requestFields == null) |
|
| 271 | 271 | $requestFields = VKUsers::standardFields; |
| 272 | 272 | $requestParameters = [ |
| 273 | 273 | 'group_id' => $groupID, |
@@ -297,7 +297,7 @@ discard block |
||
| 297 | 297 | * @param int $userID |
| 298 | 298 | * @return mixed |
| 299 | 299 | */ |
| 300 | - public function removeUser($groupID, $userID){ |
|
| 300 | + public function removeUser($groupID, $userID) { |
|
| 301 | 301 | $requestParameters = [ |
| 302 | 302 | 'group_id' => $groupID, |
| 303 | 303 | 'user_id' => $userID |
@@ -311,7 +311,7 @@ discard block |
||
| 311 | 311 | * @param int $userID |
| 312 | 312 | * @return mixed |
| 313 | 313 | */ |
| 314 | - public function approveRequest($groupID, $userID){ |
|
| 314 | + public function approveRequest($groupID, $userID) { |
|
| 315 | 315 | $requestParameters = [ |
| 316 | 316 | 'group_id' => $groupID, |
| 317 | 317 | 'user_id' => $userID |
@@ -325,7 +325,7 @@ discard block |
||
| 325 | 325 | * @param $fieldsArray |
| 326 | 326 | * @return string |
| 327 | 327 | */ |
| 328 | - private function getAllowedFields($fieldsArray){ |
|
| 328 | + private function getAllowedFields($fieldsArray) { |
|
| 329 | 329 | $groupsFields = [ |
| 330 | 330 | 'group_id', |
| 331 | 331 | 'name', |
@@ -354,7 +354,7 @@ discard block |
||
| 354 | 354 | 'contacts' |
| 355 | 355 | ]; |
| 356 | 356 | |
| 357 | - foreach($fieldsArray as $fKey => $fValue){ if(!in_array($fValue, $groupsFields)) unset($fieldsArray[$fKey]); } |
|
| 357 | + foreach ($fieldsArray as $fKey => $fValue) { if (!in_array($fValue, $groupsFields)) unset($fieldsArray[ $fKey ]); } |
|
| 358 | 358 | return implode(',', $fieldsArray); |
| 359 | 359 | } |
| 360 | 360 | } |
| 361 | 361 | \ No newline at end of file |
@@ -59,8 +59,11 @@ discard block |
||
| 59 | 59 | $requestParameters = [ |
| 60 | 60 | 'fields' => $this->getAllowedFields($requestFields) |
| 61 | 61 | ]; |
| 62 | - if(is_array($groupID)) $requestParameters['group_ids'] = implode(',', $groupID); |
|
| 63 | - else $requestParameters['group_id'] = $groupID; |
|
| 62 | + if(is_array($groupID)) { |
|
| 63 | + $requestParameters['group_ids'] = implode(',', $groupID); |
|
| 64 | + } else { |
|
| 65 | + $requestParameters['group_id'] = $groupID; |
|
| 66 | + } |
|
| 64 | 67 | |
| 65 | 68 | return parent::executeQuery(__FUNCTION__, $requestParameters); |
| 66 | 69 | } |
@@ -267,8 +270,9 @@ discard block |
||
| 267 | 270 | * @return array |
| 268 | 271 | */ |
| 269 | 272 | public function getRequests($groupID, $requestFields = null, $setCount = 20) { |
| 270 | - if($requestFields == null) |
|
| 271 | - $requestFields = VKUsers::standardFields; |
|
| 273 | + if($requestFields == null) { |
|
| 274 | + $requestFields = VKUsers::standardFields; |
|
| 275 | + } |
|
| 272 | 276 | $requestParameters = [ |
| 273 | 277 | 'group_id' => $groupID, |
| 274 | 278 | 'fields' => $requestFields, |
@@ -354,7 +358,10 @@ discard block |
||
| 354 | 358 | 'contacts' |
| 355 | 359 | ]; |
| 356 | 360 | |
| 357 | - foreach($fieldsArray as $fKey => $fValue){ if(!in_array($fValue, $groupsFields)) unset($fieldsArray[$fKey]); } |
|
| 361 | + foreach($fieldsArray as $fKey => $fValue){ if(!in_array($fValue, $groupsFields)) { |
|
| 362 | + unset($fieldsArray[$fKey]); |
|
| 363 | + } |
|
| 364 | + } |
|
| 358 | 365 | return implode(',', $fieldsArray); |
| 359 | 366 | } |
| 360 | 367 | } |
| 361 | 368 | \ No newline at end of file |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | * VKDataStorage constructor. |
| 23 | 23 | * @param VKBase $vkObject |
| 24 | 24 | */ |
| 25 | - public function __construct(VKBase $vkObject){ |
|
| 25 | + public function __construct(VKBase $vkObject) { |
|
| 26 | 26 | parent::__construct($vkObject); |
| 27 | 27 | } |
| 28 | 28 | |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | * @throws VKException |
| 36 | 36 | * @return array |
| 37 | 37 | */ |
| 38 | - protected function get($storageKey, $storageKeys, $userID, $isGlobal){ |
|
| 38 | + protected function get($storageKey, $storageKeys, $userID, $isGlobal) { |
|
| 39 | 39 | parent::isAllowed(); |
| 40 | 40 | $requestParameters = [ |
| 41 | 41 | 'key' => substr($storageKey, 0, 100), |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | * @throws VKException |
| 57 | 57 | * @return array |
| 58 | 58 | */ |
| 59 | - protected function set($storageKey, $keyValue, $userID, $isGlobal){ |
|
| 59 | + protected function set($storageKey, $keyValue, $userID, $isGlobal) { |
|
| 60 | 60 | parent::isAllowed(); |
| 61 | 61 | $requestParameters = [ |
| 62 | 62 | 'key' => substr($storageKey, 0, 100), |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | * @throws VKException |
| 78 | 78 | * @return array |
| 79 | 79 | */ |
| 80 | - protected function getKeys($userID, $isGlobal, $setOffset = 0, $returnResult = 100){ |
|
| 80 | + protected function getKeys($userID, $isGlobal, $setOffset = 0, $returnResult = 100) { |
|
| 81 | 81 | parent::isAllowed(); |
| 82 | 82 | $requestParameters = [ |
| 83 | 83 | 'user_id' => $userID, |
@@ -15,13 +15,13 @@ discard block |
||
| 15 | 15 | /** |
| 16 | 16 | * Default Filters To Be Used |
| 17 | 17 | */ |
| 18 | - const defaultFilters = ['friends', 'messages', 'groups']; |
|
| 18 | + const defaultFilters = [ 'friends', 'messages', 'groups' ]; |
|
| 19 | 19 | |
| 20 | 20 | /** |
| 21 | 21 | * VKAccount constructor. |
| 22 | 22 | * @param VKBase $vkObject |
| 23 | 23 | */ |
| 24 | - public function __construct(VKBase $vkObject){ |
|
| 24 | + public function __construct(VKBase $vkObject) { |
|
| 25 | 25 | parent::__construct($vkObject); |
| 26 | 26 | parent::isAllowed(); |
| 27 | 27 | } |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | * @param array $selectedFilters |
| 32 | 32 | * @return array |
| 33 | 33 | */ |
| 34 | - public function getCounters($selectedFilters = self::defaultFilters){ |
|
| 34 | + public function getCounters($selectedFilters = self::defaultFilters) { |
|
| 35 | 35 | $requestParameters = [ |
| 36 | 36 | 'filter' => $this->getAllowedFilters($selectedFilters) |
| 37 | 37 | ]; |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | * @param $applicationName |
| 46 | 46 | * @return mixed |
| 47 | 47 | */ |
| 48 | - public function setNameInMenu($userID, $applicationName){ |
|
| 48 | + public function setNameInMenu($userID, $applicationName) { |
|
| 49 | 49 | $requestParameters = [ |
| 50 | 50 | 'user_id' => $userID, |
| 51 | 51 | 'name' => $applicationName |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | * (This method is available only to standalone-applications.) |
| 60 | 60 | * @return mixed |
| 61 | 61 | */ |
| 62 | - public function setOnline(){ |
|
| 62 | + public function setOnline() { |
|
| 63 | 63 | $requestParameters = [ |
| 64 | 64 | 'voip' => 1 |
| 65 | 65 | ]; |
@@ -71,8 +71,8 @@ discard block |
||
| 71 | 71 | * (This method is available only to standalone-applications.) |
| 72 | 72 | * @return mixed |
| 73 | 73 | */ |
| 74 | - public function setOffline(){ |
|
| 75 | - return $this->executeQuery(__FUNCTION__, []); |
|
| 74 | + public function setOffline() { |
|
| 75 | + return $this->executeQuery(__FUNCTION__, [ ]); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | /** |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | * @param int $setCount |
| 82 | 82 | * @return array |
| 83 | 83 | */ |
| 84 | - public function getActiveOffers($setOffset = 0, $setCount = 100){ |
|
| 84 | + public function getActiveOffers($setOffset = 0, $setCount = 100) { |
|
| 85 | 85 | $requestParameters = [ |
| 86 | 86 | 'offset' => $setOffset, |
| 87 | 87 | 'count' => ($setCount > 100 || $setCount < 0) ? 100 : $setCount |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | * @param int $userID |
| 96 | 96 | * @return mixed |
| 97 | 97 | */ |
| 98 | - public function getAppPermissions($userID){ |
|
| 98 | + public function getAppPermissions($userID) { |
|
| 99 | 99 | $requestParameters = [ |
| 100 | 100 | 'user_id' => $userID |
| 101 | 101 | ]; |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | * @param $filtersArray |
| 109 | 109 | * @return string |
| 110 | 110 | */ |
| 111 | - private function getAllowedFilters($filtersArray){ |
|
| 111 | + private function getAllowedFilters($filtersArray) { |
|
| 112 | 112 | $existingFilters = [ |
| 113 | 113 | 'friends', |
| 114 | 114 | 'messages', |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | 'groups', |
| 121 | 121 | 'sdk' |
| 122 | 122 | ]; |
| 123 | - foreach($filtersArray as $fKey => $fValue){ if(!in_array($fValue, $existingFilters)) unset($filtersArray[$fKey]); } |
|
| 123 | + foreach ($filtersArray as $fKey => $fValue) { if (!in_array($fValue, $existingFilters)) unset($filtersArray[ $fKey ]); } |
|
| 124 | 124 | return implode(',', $filtersArray); |
| 125 | 125 | } |
| 126 | 126 | } |
| 127 | 127 | \ No newline at end of file |
@@ -120,7 +120,10 @@ |
||
| 120 | 120 | 'groups', |
| 121 | 121 | 'sdk' |
| 122 | 122 | ]; |
| 123 | - foreach($filtersArray as $fKey => $fValue){ if(!in_array($fValue, $existingFilters)) unset($filtersArray[$fKey]); } |
|
| 123 | + foreach($filtersArray as $fKey => $fValue){ if(!in_array($fValue, $existingFilters)) { |
|
| 124 | + unset($filtersArray[$fKey]); |
|
| 125 | + } |
|
| 126 | + } |
|
| 124 | 127 | return implode(',', $filtersArray); |
| 125 | 128 | } |
| 126 | 129 | } |
| 127 | 130 | \ No newline at end of file |