diff --git a/README.md b/README.md index a34c4a2..562139c 100755 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ PHP library for VK API interaction, includes OAuth 2.0 authorization and API methods. Full VK API features documentation can be found [here](http://vk.com/dev). -This library has been created using the VK API JSON Schema. It can be found [here](https://github.com/VKCOM/vk-api-schema). It uses VK API [version](https://vk.com/dev/versions) 5.101 +This library has been created using the VK API JSON Schema. It can be found [here](https://github.com/VKCOM/vk-api-schema). It uses VK API [version](https://vk.com/dev/versions) 5.120 [![Packagist](https://img.shields.io/packagist/v/vkcom/vk-php-sdk.svg)](https://packagist.org/packages/vkcom/vk-php-sdk) @@ -29,11 +29,11 @@ $vk = new VK\Client\VKApiClient(); Also you can initialize `VKApiClient` with different API version and different language like this: ```php -$vk = new VKApiClient('5.101'); +$vk = new VKApiClient('5.120'); ``` ```php -$vk = new VKApiClient('5.101', VK\Client\Enums\VKLanguage::ENGLISH); +$vk = new VKApiClient('5.120', VK\Client\Enums\VKLanguage::ENGLISH); ``` ## 4. Authorization @@ -88,7 +88,7 @@ Then use this method to get the access token: ```php $oauth = new VK\OAuth\VKOAuth(); $client_id = 1234567; -$client_secret = 'SDAScasd' +$client_secret = 'SDAScasd'; $redirect_uri = 'https://example.com/vk'; $code = 'CODE'; diff --git a/src/VK/Actions/AppWidgets.php b/src/VK/Actions/AppWidgets.php index fb2d9aa..14896d6 100644 --- a/src/VK/Actions/AppWidgets.php +++ b/src/VK/Actions/AppWidgets.php @@ -30,11 +30,129 @@ public function __construct(VKApiRequest $request) { $this->request = $request; } + /** + * Returns URL to upload an app widget photo. + * + * @param string $access_token + * @param array $params + * - @var string image_type: Type of image. Values: *'24x24',, *'50x50',, *'160x160',, *'160x240',, *'510x128' + * @throws VKClientException + * @throws VKApiException + * @throws VKApiCompileException Unable to compile code + * @throws VKApiRuntimeException Runtime error occurred during code invocation + * @return mixed + */ + public function getAppImageUploadServer($access_token, $params = []) { + return $this->request->post('appWidgets.getAppImageUploadServer', $access_token, $params); + } + + /** + * Returns a collection of application images. + * + * @param string $access_token + * @param array $params + * - @var integer offset: Offset needed to return a specific subset of images. + * - @var integer count: Number of objects to return. + * - @var string image_type: Type of image. Values: *'24x24',, *'50x50',, *'160x160',, *'160x240',, *'510x128' + * @throws VKClientException + * @throws VKApiException + * @throws VKApiCompileException Unable to compile code + * @throws VKApiRuntimeException Runtime error occurred during code invocation + * @return mixed + */ + public function getAppImages($access_token, $params = []) { + return $this->request->post('appWidgets.getAppImages', $access_token, $params); + } + + /** + * Returns the server address for community photo upload. + * + * @param string $access_token + * @param array $params + * - @var string image_type: Type of image. Values: *'24x24',, *'50x50',, *'160x160',, *'160x240',, *'510x128' + * @throws VKClientException + * @throws VKApiException + * @throws VKApiCompileException Unable to compile code + * @throws VKApiRuntimeException Runtime error occurred during code invocation + * @return mixed + */ + public function getGroupImageUploadServer($access_token, $params = []) { + return $this->request->post('appWidgets.getGroupImageUploadServer', $access_token, $params); + } + + /** + * Returns a collection of application images. + * + * @param string $access_token + * @param array $params + * - @var integer offset: Offset needed to return a specific subset of images. + * - @var integer count: Number of objects to return. + * - @var string image_type: Type of image. Values: *'24x24',, *'50x50',, *'160x160',, *'160x240',, *'510x128' + * @throws VKClientException + * @throws VKApiException + * @throws VKApiCompileException Unable to compile code + * @throws VKApiRuntimeException Runtime error occurred during code invocation + * @return mixed + */ + public function getGroupImages($access_token, $params = []) { + return $this->request->post('appWidgets.getGroupImages', $access_token, $params); + } + + /** + * Returns a collection of application images by id. + * + * @param string $access_token + * @param array $params + * - @var array[string] images: List of images ID + * @throws VKClientException + * @throws VKApiException + * @throws VKApiCompileException Unable to compile code + * @throws VKApiRuntimeException Runtime error occurred during code invocation + * @return mixed + */ + public function getGroupImagesById($access_token, $params = []) { + return $this->request->post('appWidgets.getGroupImagesById', $access_token, $params); + } + + /** + * Saves app photos after successful uploading. + * + * @param string $access_token + * @param array $params + * - @var string hash: Parameter returned when photos are [vk.com/dev/upload_files|uploaded to server]. + * - @var string image: Parameter returned when photos are [vk.com/dev/upload_files|uploaded to server]. + * @throws VKClientException + * @throws VKApiException + * @throws VKApiCompileException Unable to compile code + * @throws VKApiRuntimeException Runtime error occurred during code invocation + * @return mixed + */ + public function saveAppImage($access_token, $params = []) { + return $this->request->post('appWidgets.saveAppImage', $access_token, $params); + } + + /** + * Saves app photos into community after successful uploading. + * + * @param string $access_token + * @param array $params + * - @var string hash: Parameter returned when photos are [vk.com/dev/upload_files|uploaded to server]. + * - @var string image: Parameter returned when photos are [vk.com/dev/upload_files|uploaded to server]. + * @throws VKClientException + * @throws VKApiException + * @throws VKApiCompileException Unable to compile code + * @throws VKApiRuntimeException Runtime error occurred during code invocation + * @return mixed + */ + public function saveGroupImage($access_token, $params = []) { + return $this->request->post('appWidgets.saveGroupImage', $access_token, $params); + } + /** * Allows to update community app widget * * @param string $access_token - * @param array $params + * @param array $params * - @var string code * - @var AppWidgetsType type * @throws VKClientException diff --git a/src/VK/Actions/Apps.php b/src/VK/Actions/Apps.php index c00b12d..fd9a03c 100644 --- a/src/VK/Actions/Apps.php +++ b/src/VK/Actions/Apps.php @@ -45,7 +45,7 @@ public function deleteAppRequests($access_token) { * Returns applications data. * * @param string $access_token - * @param array $params + * @param array $params * - @var integer app_id: Application ID * - @var array[string] app_ids: List of application ID * - @var AppsPlatform platform: platform. Possible values: *'ios' — iOS,, *'android' — Android,, *'winphone' — Windows Phone,, *'web' — приложения на vk.com. By default: 'web'. @@ -65,7 +65,7 @@ public function get($access_token, array $params = []) { * Returns a list of applications (apps) available to users in the App Catalog. * * @param string $access_token - * @param array $params + * @param array $params * - @var AppsSort sort: Sort order: 'popular_today' — popular for one day (default), 'visitors' — by visitors number , 'create_date' — by creation date, 'growth_rate' — by growth rate, 'popular_week' — popular for one week * - @var integer offset: Offset required to return a specific subset of apps. * - @var integer count: Number of apps to return. @@ -89,7 +89,7 @@ public function getCatalog($access_token, array $params = []) { * Creates friends list for requests and invites in current app. * * @param string $access_token - * @param array $params + * @param array $params * - @var boolean extended * - @var integer count: List size. * - @var integer offset @@ -107,7 +107,7 @@ public function getFriendsList($access_token, array $params = []) { * Returns players rating in the game. * * @param string $access_token - * @param array $params + * @param array $params * - @var AppsType type: Leaderboard type. Possible values: *'level' — by level,, *'points' — by mission points,, *'score' — by score (). * - @var boolean global: Rating type. Possible values: *'1' — global rating among all players,, *'0' — rating among user friends. * - @var boolean extended: 1 — to return additional info about users @@ -123,7 +123,7 @@ public function getLeaderboard($access_token, array $params = []) { * Returns scopes for auth * * @param string $access_token - * @param array $params + * @param array $params * - @var AppsType type * @throws VKClientException * @throws VKApiException @@ -137,7 +137,7 @@ public function getScopes($access_token, array $params = []) { * Returns user score in app * * @param string $access_token - * @param array $params + * @param array $params * - @var integer user_id * @throws VKClientException * @throws VKApiException @@ -151,7 +151,7 @@ public function getScore($access_token, array $params = []) { * Sends a request to another user in an app that uses VK authorization. * * @param string $access_token - * @param array $params + * @param array $params * - @var integer user_id: id of the user to send a request * - @var string text: request text * - @var AppsType type: request type. Values: 'invite' – if the request is sent to a user who does not have the app installed,, 'request' – if a user has already installed the app diff --git a/src/VK/Actions/Groups.php b/src/VK/Actions/Groups.php index 77f9bc4..a8614da 100644 --- a/src/VK/Actions/Groups.php +++ b/src/VK/Actions/Groups.php @@ -166,6 +166,23 @@ public function create($access_token, array $params = []) { return $this->request->post('groups.create', $access_token, $params); } + /** + * Delete community address. + * + * @param string $access_token + * @param array $params + * - @var integer group_id: Group ID + * - @var integer address_id: Address ID + * @throws VKClientException + * @throws VKApiException + * @throws VKApiAccessGroupsException Access to the groups list is denied due to the user's privacy settings + * @throws VKApiNotFoundException Not found + * @return mixed + */ + public function deleteAddress($access_token, array $params = []) { + return $this->request->post('groups.deleteAddress', $access_token, $params); + } + /** * @param string $access_token * @param array $params @@ -597,6 +614,21 @@ public function getMembers($access_token, array $params = []) { return $this->request->post('groups.getMembers', $access_token, $params); } + /** + * Returns online status of community. + * + * @param string $access_token + * @param array $params + * - @var integer group_id: ID of the community. + * @throws VKClientException + * @throws VKApiException + * @throws VKApiParamGroupIdException Invalid group id + * @return mixed + */ + public function getOnlineStatus($access_token, array $params = []) { + return $this->request->post('groups.getOnlineStatus', $access_token, $params); + } + /** * Returns a list of requests to the community. * @@ -628,6 +660,20 @@ public function getSettings($access_token, array $params = []) { return $this->request->post('groups.getSettings', $access_token, $params); } + /** + * Returns list of community tags. + * + * @param string $access_token + * @param array $params + * - @var integer group_id: Community ID. + * @throws VKClientException + * @throws VKApiException + * @return mixed + */ + public function getTagList($access_token, array $params = []) { + return $this->request->post('groups.getTagList', $access_token, $params); + } + /** * @param string $access_token * @throws VKClientException @@ -866,6 +912,104 @@ public function setLongPollSettings($access_token, array $params = []) { return $this->request->post('groups.setLongPollSettings', $access_token, $params); } + /** + * Sets community settings + * + * @param string $access_token + * @param array $params + * - @var integer group_id: Community ID. + * - @var boolean messages: Sets whether messages is enabled ('0' — disabled, '1' — enabled). + * - @var boolean bots_capabilities: Sets whether bots capabilities is enabled ('0' — disabled, '1' — enabled). + * - @var boolean bots_start_button: Start button ('0' — disabled, '1' — enabled). + * - @var boolean bots_add_to_chat: Users can add bots to conversations ('0' — disabled, '1' — enabled). + * @throws VKClientException + * @throws VKApiException + * @return mixed + */ + public function setSettings($access_token, array $params = []) { + return $this->request->post('groups.setSettings', $access_token, $params); + } + + /** + * Set or update user note + * + * @param string $access_token + * @param array $params + * - @var integer group_id: Community ID. + * - @var integer user_id: User ID. + * - @var string note: Note text. + * @throws VKClientException + * @throws VKApiException + * @return mixed + */ + public function setUserNote($access_token, array $params = []) { + return $this->request->post('groups.setUserNote', $access_token, $params); + } + + /** + * Add new tag to community + * + * @param string $access_token + * @param array $params + * - @var integer group_id: Community ID. + * - @var string tag_name: Name of tag. + * - @var string tag_color: Color of tag. + * @throws VKClientException + * @throws VKApiException + * @return mixed + */ + public function tagAdd($access_token, array $params = []) { + return $this->request->post('groups.tagAdd', $access_token, $params); + } + + /** + * Bind and unbind community's tags to conversations. + * + * @param string $access_token + * @param array $params + * - @var integer group_id: Community ID. + * - @var integer tag_id: Tag ID. + * - @var integer user_id: User ID. + * - @var string act: Tag Action. Values: *'bind',, *'unbind' + * @throws VKClientException + * @throws VKApiException + * @return mixed + */ + public function tagBind($access_token, array $params = []) { + return $this->request->post('groups.tagBind', $access_token, $params); + } + + /** + * Delete tag of community + * + * @param string $access_token + * @param array $params + * - @var integer group_id: Community ID. + * - @var integer tag_id: Tag ID. + * @throws VKClientException + * @throws VKApiException + * @return mixed + */ + public function tagDelete($access_token, array $params = []) { + return $this->request->post('groups.tagDelete', $access_token, $params); + } + + /** + * Update tag of community + * + * @param string $access_token + * @param array $params + * - @var integer group_id: Community ID. + * - @var integer tag_id: Tag ID. + * - @var string tag_name: Tag Name. + * @throws VKClientException + * @throws VKApiException + * @return mixed + */ + public function tagUpdate($access_token, array $params = []) { + return $this->request->post('groups.tagUpdate', $access_token, $params); + } + /** * @param string $access_token * @param array $params diff --git a/src/VK/Actions/Messages.php b/src/VK/Actions/Messages.php index 636d2cb..4c6279d 100644 --- a/src/VK/Actions/Messages.php +++ b/src/VK/Actions/Messages.php @@ -371,6 +371,26 @@ public function getHistoryAttachments($access_token, array $params = []) { return $this->request->post('messages.getHistoryAttachments', $access_token, $params); } + /** + * Returns important messages from the dialog or group chat. + * + * @param string $access_token + * @param array $params + * - @var integer count: Number of objects to return. + * - @var integer offset: Offset needed to return a specific subset of messages. + * - @var string start_message_id: Message ID to start return results from. + * - @var integer preview_length + * - @var array[MessagesFields] fields: Additional profile [vk.com/dev/fields|fields] to return. + * - @var boolean extended: '1' — return extra information about users and communities + * - @var integer group_id: Group ID (for group messages with group access token) + * @throws VKClientException + * @throws VKApiException + * @return mixed + */ + public function getImportantMessages($access_token, array $params = []) { + return $this->request->post('messages.getImportantMessages', $access_token, $params); + } + /** * @param string $access_token * @param array $params @@ -671,6 +691,23 @@ public function send($access_token, array $params = []) { return $this->request->post('messages.send', $access_token, $params); } + /** + * Sends a message event answer. + * + * @param string $access_token + * @param array $params + * - @var integer event_id: Event ID. + * - @var integer user_id: User ID (by default — current user). + * - @var integer peer_id: Destination ID. "For user: 'User ID', e.g. '12345'. For chat: '2000000000' + 'chat_id', e.g. '2000000001'. For community: '- community ID', e.g. '-12345'. " + * - @var string event_data + * @throws VKClientException + * @throws VKApiException + * @return mixed + */ + public function sendMessageEventAnswer($access_token, array $params = []) { + return $this->request->post('messages.sendMessageEventAnswer', $access_token, $params); + } + /** * Changes the status of a user as typing in a conversation. * diff --git a/src/VK/Client/VKApiClient.php b/src/VK/Client/VKApiClient.php index 03f5b34..2e9c887 100755 --- a/src/VK/Client/VKApiClient.php +++ b/src/VK/Client/VKApiClient.php @@ -2,10 +2,10 @@ namespace VK\Client; -use VK\Client\Enums\VKLanguage; use VK\Actions\Account; use VK\Actions\Ads; use VK\Actions\Apps; +use VK\Actions\AppWidgets; use VK\Actions\Auth; use VK\Actions\Board; use VK\Actions\Database; @@ -24,7 +24,6 @@ use VK\Actions\Orders; use VK\Actions\Pages; use VK\Actions\Photos; -use VK\Actions\Places; use VK\Actions\Polls; use VK\Actions\Search; use VK\Actions\Secure; @@ -40,7 +39,7 @@ use VK\Actions\Widgets; class VKApiClient { - protected const API_VERSION = '5.101'; + protected const API_VERSION = '5.120'; protected const API_HOST = 'https://api.vk.com/method'; /** @@ -63,6 +62,11 @@ class VKApiClient { */ private $apps; + /** + * @var AppWidgets + */ + private $appWidgets; + /** * @var Auth */ @@ -83,6 +87,11 @@ class VKApiClient { */ private $docs; + /** + * @var + */ + private $execute; + /** * @var Fave */ @@ -153,11 +162,6 @@ class VKApiClient { */ private $photos; - /** - * @var Places - */ - private $places; - /** * @var Polls */ @@ -272,6 +276,17 @@ public function apps(): Apps { return $this->apps; } + /** + * @return AppWidgets + */ + public function appWidgets(): AppWidgets { + if (!$this->appWidgets) { + $this->appWidgets = new AppWidgets($this->request); + } + + return $this->appWidgets; + } + /** * @return Auth */ @@ -316,6 +331,21 @@ public function docs(): Docs { return $this->docs; } + /** + * @param string $access_token + * @param array $params + * - @var string code: VKScript code + * + * @return array + */ + public function execute($access_token, $params = []): array { + if (!$this->execute) { + $this->execute = $this->request->post('execute', $access_token, $params); + } + + return $this->execute; + } + /** * @return Fave */ @@ -470,17 +500,6 @@ public function photos(): Photos { return $this->photos; } - /** - * @return Places - */ - public function places(): Places { - if (!$this->places) { - $this->places = new Places($this->request); - } - - return $this->places; - } - /** * @return Polls */ diff --git a/src/VK/OAuth/VKOAuth.php b/src/VK/OAuth/VKOAuth.php index 7aefd76..337d85d 100755 --- a/src/VK/OAuth/VKOAuth.php +++ b/src/VK/OAuth/VKOAuth.php @@ -9,7 +9,7 @@ use VK\TransportClient\TransportRequestException; class VKOAuth { - protected const VERSION = '5.101'; + protected const VERSION = '5.120'; private const PARAM_VERSION = 'v'; private const PARAM_CLIENT_ID = 'client_id';