atehnix / vk-client
PHP client for Vk.com API
Installs: 40 956
Dependents: 6
Suggesters: 0
Security: 0
Stars: 60
Watchers: 9
Forks: 14
Open Issues: 0
Requires
- guzzlehttp/guzzle: ~6.0|~7.0
This package is not auto-updated.
Last update: 2024-02-19 13:25:16 UTC
README
Installation
You can get library and all of it dependencies through composer
composer require atehnix/vk-client
Usage
Simple example
$api = new Client; $response = $api->request('wall.get', ['owner_id' => 1]);
Use Request class
$api = new Client; $request = new Request('wall.get', ['owner_id' => 1]); $response = $api->send($request);
Use ExecuteRequest class
Send multiple requests at once
$api = new Client; $execute = ExecuteRequest::make([ new Request('wall.get', ['owner_id' => 1]), new Request('wall.get', ['owner_id' => 2]), // ... few requests new Request('wall.get', ['owner_id' => 25]), ]); $response = $api->send($execute);
Use a specific version of the API.
$api = new Client('5.60');
Use with access token
Set default token in client.
$api = new Client; $api->setDefaultToken("some_token"); // ...
Or set token for specific request.
$api = new Client; // Token in the request is a higher priority than the default token. $request = new Request('wall.get', ['owner_id' => 1], "some_token"); // ...
Authorization
$auth = new Auth('client_id', 'client_secret', 'redirect_uri'); echo "<a href='{$auth->getUrl()}'>ClickMe<a>"; // ... $token = $auth->getToken($_GET['code']);