PHPackages                             dimaspace/vkapi - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. dimaspace/vkapi

ActiveLibrary[API Development](/categories/api)

dimaspace/vkapi
===============

Laravel helper for performing requests to VK API

0519PHP

Since Jun 10Pushed 6y agoCompare

[ Source](https://github.com/di-space/laravel-vkapi)[ Packagist](https://packagist.org/packages/dimaspace/vkapi)[ RSS](/packages/dimaspace-vkapi/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel VK API class
====================

[](#laravel-vk-api-class)

Install
-------

[](#install)

Via Composer

```
$ composer require bafoed/vkapi
$ php artisan vendor:publish
```

After updating composer, add the service provider to the `providers` array in `config/app.php`

```
bafoed\VKAPI\VKAPIServiceProvider::class,
```

Also you can add alias to the `aliases` array in `config/app.php`

```
'VKAPI'     => bafoed\VKAPI\Facades\VKAPI::class,
```

Do not forget to change `access_token` in `config/VKAPI.php`

Usage
-----

[](#usage)

Simple example (access\_token is loaded from `config/VKAPI.php`)

```
    try {
        $result = VKAPI::call('users.get', ['user_ids' => '1,2,3']);
        foreach ($result as $user) {
            echo $user['first_name'] . ' ' . $user['last_name'] . PHP_EOL;
        }
    } catch(\bafoed\VKAPI\VKAPIException $e) {
        echo 'Something wrong: ' . $e->message;
    }
```

You can change access\_token at runtime using `setAccessToken` method

```
VKAPI::setAccessToken('>>> INSERT TOKEN HERE
