|
@@ -95,7 +95,7 @@ discard block |
|
|
block discarded – undo |
95
|
95
|
if (!$this->isPermissionsMaskSet) { |
96
|
96
|
$VKUser = new VKUsers($this); |
97
|
97
|
$VKAccount = new VKAccount($this); |
98
|
|
- $CurrentUser = $VKUser->get([ '' ])[ 'response' ][0][ 'uid' ]; |
|
98
|
+ $CurrentUser = $VKUser->get([ '' ])[ 'response' ][ 0 ][ 'uid' ]; |
99
|
99
|
$this->setPermissionsMask($VKAccount->getAppPermissions($CurrentUser)[ 'response' ]); |
100
|
100
|
$this->isPermissionsMaskSet = true; |
101
|
101
|
unset($VKUser); |
|
@@ -126,7 +126,7 @@ discard block |
|
|
block discarded – undo |
126
|
126
|
* @return string |
127
|
127
|
*/ |
128
|
128
|
public function getAPIUrl($apiMethod, $responseFormat = 'json') { |
129
|
|
- return self::METHOD_URL . $apiMethod . '.' . $responseFormat; |
|
129
|
+ return self::METHOD_URL.$apiMethod.'.'.$responseFormat; |
130
|
130
|
} |
131
|
131
|
|
132
|
132
|
/** |
|
@@ -176,7 +176,7 @@ discard block |
|
|
block discarded – undo |
176
|
176
|
|
177
|
177
|
try { |
178
|
178
|
if (isset($apiResponse[ 'error' ])) { |
179
|
|
- throw new VKException($apiResponse[ 'error' ] . (!isset($apiResponse[ 'error_description' ]) ?: ': ' . $apiResponse[ 'error_description' ]), '0'); |
|
179
|
+ throw new VKException($apiResponse[ 'error' ].(!isset($apiResponse[ 'error_description' ]) ?: ': '.$apiResponse[ 'error_description' ]), '0'); |
180
|
180
|
} else { |
181
|
181
|
$this->authorizationStatus = true; |
182
|
182
|
$this->accessToken = $apiResponse[ 'access_token' ]; |
|
@@ -184,7 +184,7 @@ discard block |
|
|
block discarded – undo |
184
|
184
|
} |
185
|
185
|
} catch (VKException $ex) { |
186
|
186
|
echo $ex->getMessage(); |
187
|
|
- return []; |
|
187
|
+ return [ ]; |
188
|
188
|
} |
189
|
189
|
} |
190
|
190
|
|
|
@@ -205,7 +205,7 @@ discard block |
|
|
block discarded – undo |
205
|
205
|
* @param string $requestMethod |
206
|
206
|
* @return mixed |
207
|
207
|
*/ |
208
|
|
- public function apiQuery($apiMethod, $requestParameters = [], $resultType = 'array', $requestMethod = 'get') { |
|
208
|
+ public function apiQuery($apiMethod, $requestParameters = [ ], $resultType = 'array', $requestMethod = 'get') { |
209
|
209
|
$requestParameters[ 'timestamp' ] = time(); |
210
|
210
|
$requestParameters[ 'api_id' ] = $this->applicationID; |
211
|
211
|
$requestParameters[ 'random' ] = rand(0, 10000); |
|
@@ -225,7 +225,7 @@ discard block |
|
|
block discarded – undo |
225
|
225
|
if (is_array($pValue)) { |
226
|
226
|
$pValue = implode(', ', $pValue); |
227
|
227
|
} |
228
|
|
- $parametersSignature .= $pKey . '=' . $pValue; |
|
228
|
+ $parametersSignature .= $pKey.'='.$pValue; |
229
|
229
|
} |
230
|
230
|
$parametersSignature .= $this->APISecret; |
231
|
231
|
|
|
@@ -244,9 +244,9 @@ discard block |
|
|
block discarded – undo |
244
|
244
|
} |
245
|
245
|
|
246
|
246
|
return $resultType == 'array' ? $decodedJSON : $apiResponse; |
247
|
|
- } catch(VKException $ex) { |
|
247
|
+ } catch (VKException $ex) { |
248
|
248
|
echo $ex->getMessage(); |
249
|
|
- return []; |
|
249
|
+ return [ ]; |
250
|
250
|
} |
251
|
251
|
} |
252
|
252
|
|
|
@@ -273,7 +273,7 @@ discard block |
|
|
block discarded – undo |
273
|
273
|
* @return string |
274
|
274
|
*/ |
275
|
275
|
private function createURL($urlString, $parametersArray) { |
276
|
|
- $urlString .= '?' . http_build_query($parametersArray); |
|
276
|
+ $urlString .= '?'.http_build_query($parametersArray); |
277
|
277
|
return $urlString; |
278
|
278
|
} |
279
|
279
|
|
|
@@ -284,9 +284,9 @@ discard block |
|
|
block discarded – undo |
284
|
284
|
* @param array $postFields |
285
|
285
|
* @return string |
286
|
286
|
*/ |
287
|
|
- private function performRequest($requestURL, $requestMethod = 'GET', $postFields = []) { |
|
287
|
+ private function performRequest($requestURL, $requestMethod = 'GET', $postFields = [ ]) { |
288
|
288
|
curl_setopt_array($this->curlObject, [ |
289
|
|
- CURLOPT_USERAGENT => 'FreedomCore/' . self::PACKAGE_VERSION . ' VK OAuth Client', |
|
289
|
+ CURLOPT_USERAGENT => 'FreedomCore/'.self::PACKAGE_VERSION.' VK OAuth Client', |
290
|
290
|
CURLOPT_RETURNTRANSFER => true, |
291
|
291
|
CURLOPT_SSL_VERIFYPEER => false, |
292
|
292
|
CURLOPT_POST => ($requestMethod == 'POST'), |
|
@@ -341,42 +341,42 @@ discard block |
|
|
block discarded – undo |
341
|
341
|
*/ |
342
|
342
|
private function codeToErrorText($Code) { |
343
|
343
|
$errorsData = [ |
344
|
|
- 1 => [ 'title' => 'Unknown error occurred', 'description' => 'Try again later.' ], |
345
|
|
- 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).' ], |
346
|
|
- 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> ' ], |
347
|
|
- 4 => [ 'title' => 'Incorrect signature ', 'description' => 'Check if the signature has been formed correctly: <a href="https://vk.com/dev/api_nohttps" target="_blank"></a>' ], |
348
|
|
- 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.' ], |
349
|
|
- 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>' ], |
350
|
|
- 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.' ], |
351
|
|
- 8 => [ 'title' => 'Invalid request ', 'description' => 'Check the request syntax and used parameters list (it can be found on a method description page) ' ], |
352
|
|
- 9 => [ 'title' => 'Flood control ', 'description' => 'You need to decrease the count of identical requests. For more efficient work you may use execute or JSONP.' ], |
353
|
|
- 10 => [ 'title' => 'Internal server error', 'description' => 'Try again later.' ], |
354
|
|
- 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}.' ], |
355
|
|
- 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>' ], |
356
|
|
- 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.' ], |
357
|
|
- 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.' ], |
358
|
|
- 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>.' ], |
359
|
|
- 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.' ], |
360
|
|
- 21 => [ 'title' => 'Permission to perform this action is allowed only for Standalone and OpenAPI applications', 'description' => '' ], |
361
|
|
- 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>' ], |
362
|
|
- 24 => [ 'title' => 'Confirmation required ', 'description' => 'Confirmation process is described on the <a href="https://vk.com/dev/need_confirmation" target="_blank">separate page</a>' ], |
363
|
|
- 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.' ], |
364
|
|
- 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.' ], |
|
344
|
+ 1 => [ 'title' => 'Unknown error occurred', 'description' => 'Try again later.' ], |
|
345
|
+ 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).' ], |
|
346
|
+ 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> ' ], |
|
347
|
+ 4 => [ 'title' => 'Incorrect signature ', 'description' => 'Check if the signature has been formed correctly: <a href="https://vk.com/dev/api_nohttps" target="_blank"></a>' ], |
|
348
|
+ 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.' ], |
|
349
|
+ 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>' ], |
|
350
|
+ 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.' ], |
|
351
|
+ 8 => [ 'title' => 'Invalid request ', 'description' => 'Check the request syntax and used parameters list (it can be found on a method description page) ' ], |
|
352
|
+ 9 => [ 'title' => 'Flood control ', 'description' => 'You need to decrease the count of identical requests. For more efficient work you may use execute or JSONP.' ], |
|
353
|
+ 10 => [ 'title' => 'Internal server error', 'description' => 'Try again later.' ], |
|
354
|
+ 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}.' ], |
|
355
|
+ 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>' ], |
|
356
|
+ 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.' ], |
|
357
|
+ 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.' ], |
|
358
|
+ 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>.' ], |
|
359
|
+ 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.' ], |
|
360
|
+ 21 => [ 'title' => 'Permission to perform this action is allowed only for Standalone and OpenAPI applications', 'description' => '' ], |
|
361
|
+ 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>' ], |
|
362
|
+ 24 => [ 'title' => 'Confirmation required ', 'description' => 'Confirmation process is described on the <a href="https://vk.com/dev/need_confirmation" target="_blank">separate page</a>' ], |
|
363
|
+ 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.' ], |
|
364
|
+ 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.' ], |
365
|
365
|
103 => [ 'title' => 'Out of limits', 'description' => 'Out of limits' ], |
366
|
366
|
104 => [ 'title' => 'Not found', 'description' => 'Not found' ], |
367
|
|
- 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' ], |
368
|
|
- 150 => [ 'title' => 'Invalid timestamp ', 'description' => 'You may get a correct value with the utils.getServerTime method.' ], |
369
|
|
- 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.' ], |
370
|
|
- 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.' ], |
371
|
|
- 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).' ], |
372
|
|
- 300 => [ 'title' => 'This album is full ', 'description' => 'You need to delete the odd objects from the album or use another album.' ], |
373
|
|
- 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' ], |
374
|
|
- 600 => [ 'title' => 'Permission denied. You have no access to operations specified with given object(s)', 'description' => '' ], |
375
|
|
- 603 => [ 'title' => 'Some ads error occurred', 'description' => '' ], |
376
|
|
- 1260 => [ 'title' => 'Invalid screen name', 'description' => 'This screen name is already in use or invalid' ], |
|
367
|
+ 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' ], |
|
368
|
+ 150 => [ 'title' => 'Invalid timestamp ', 'description' => 'You may get a correct value with the utils.getServerTime method.' ], |
|
369
|
+ 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.' ], |
|
370
|
+ 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.' ], |
|
371
|
+ 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).' ], |
|
372
|
+ 300 => [ 'title' => 'This album is full ', 'description' => 'You need to delete the odd objects from the album or use another album.' ], |
|
373
|
+ 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' ], |
|
374
|
+ 600 => [ 'title' => 'Permission denied. You have no access to operations specified with given object(s)', 'description' => '' ], |
|
375
|
+ 603 => [ 'title' => 'Some ads error occurred', 'description' => '' ], |
|
376
|
+ 1260 => [ 'title' => 'Invalid screen name', 'description' => 'This screen name is already in use or invalid' ], |
377
|
377
|
]; |
378
|
378
|
|
379
|
|
- return (!array_key_exists($Code, $errorsData)) ? $errorsData[1] : $errorsData[$Code]; |
|
379
|
+ return (!array_key_exists($Code, $errorsData)) ? $errorsData[ 1 ] : $errorsData[ $Code ]; |
380
|
380
|
} |
381
|
381
|
|
382
|
382
|
} |
383
|
383
|
\ No newline at end of file |