Download the PHP package vk/php-sdk without Composer

On this page you can find all versions of the php package vk/php-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package php-sdk

vk-php-sdk

PHP library for VK API interaction, includes OAuth 2.0 authorization and API methods. Full VK API features documentation can be found here.

This library has been created using the VK API JSON Schema. It can be found here. It uses VK API version 5.69.

1. Installation

The VK PHP SDK can be installed using Composer by running the following command:

2. Initialization

Create VKAPIClient object using the following code:

3. Authorization

The library provides the authorization flows for user based on OAuth 2.0 protocol implementation in vk.com API. Please read the full documentation before you start.

3.1. Authorization Code Flow for User

OAuth 2.0 Authorization Code Flow allows calling methods from the server side.

This flow includes two steps — obtaining an authorization code and exchanging the code for an access token. Primarily you should obtain the "code" (manual) by redirecting the user to the authorization page using the following method:

As a '{display}' you should pass a constant from the OAuthDisplay class. The '{scope_array}' should be an array of constants from the OAuthUserScope class.

Example:

After successful authorization user's browser will be redirected to the specified redirect_uri. Meanwhile the code will be sent as a GET parameter to the specified address:

Then use this method to get the access token:

The '{redirect_uri}' should be the URL that was used to get a code at the first step.

Example:

4. API Requests

You can find the full list of VK API methods here.

Request sample

Example of calling method users.get:

Uploading Photos into a Private Message

Please read the full manual before the start.

Call photos.getMessagesUploadServer to receive an upload address:

Then use upload() method to send files to the upload_url address received in the previous step:

You will get a JSON object with server, photo, hash fields. To save a photo call photos.saveMessagesPhoto with these three parameters:

Then you can use 'owner_id' and 'id' parameters from the last response to create an attachment of the uploaded photo.

Uploading Video Files

Please read the full manual before the start.

Call video.save to get a video upload server address:

Send a file to upload_url received previously calling upload() method:

Videos are processed for some time after uploading.

6. Callback API LongPoll handler

Enable Callback API LongPoll for your group and specify which events should be tracked by calling the following API method:

Override methods from CallbackApiHandler class for handling events:

To start listening to LongPoll events, create an instance of your CallbackAPIMyHandler class, instance of CallbackApiLongPollExecutor class and call method run():

Parameter '{wait}' is the waiting period.

While calling function listen() you can also specify the number of the event from which you want to receive data. The default value is the number of the last event.

Example:


All versions of php-sdk with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4
vkcom/vk-api-schema Version ^1.4.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package vk/php-sdk contains the following files

Loading the files please wait ....