composer require labile/kphp-vk-utils
use Astaroth\VkUtils\Client;
$api = new Client;
$response = $api->request('wall.get', ['owner_id' => 1]);
use Astaroth\VkUtils\Client;
use Astaroth\VkUtils\Requests\Request;
$api = new Client;
$request = new Request('wall.get', ['owner_id' => 1]);
$response = $api->send($request);
Sending multiple requests at the same time
use Astaroth\VkUtils\Execute;
use Astaroth\VkUtils\Requests\Request;
$api = new Execute;
$api->setDefaultToken('PUT ACCESS TOKEN');
$execute = [
new Request('wall.get', ['owner_id' => 1]),
new Request('wall.get', ['owner_id' => 2]),
// ...more request
new Request('wall.get', ['owner_id' => 25]),
];
$response = $api->send($execute);
use Astaroth\VkUtils\Client;
$api = new Client('5.131');
Set default token in client
use Astaroth\VkUtils\Client;
$api = new Client();
$api->setDefaultToken("PUT TOKEN");
or so
use Astaroth\VkUtils\Requests\Request;
use Astaroth\VkUtils\Client;
$api = new Client;
// The token in the request takes precedence over setDefaultToken
$request = new Request('wall.get', ['owner_id' => 1], "some_token");
use Astaroth\VkUtils\Builders\Attachments\Message\Graffiti;
use Astaroth\VkUtils\Builders\Attachments\Photo;
use Astaroth\VkUtils\Builders\Attachments\Video;
use Astaroth\VkUtils\Uploader;
use Astaroth\VkUtils\Builders\Attachments\Message\AudioMessage;
$uploader = new Uploader();
$uploader->setDefaultToken('PUT TOKEN');
$attachments = $uploader->upload
(
new Photo("dog.jpg"),
new AudioMessage('meow.mp3'),
//downloading from the link temporarily does not work
(new Video('https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerEscapes.mp4'))
->setName('4 Biggers Escapes')
->setDescription('The video has nothing interesting, just an example')
->setWallpost(true),
new Graffiti('cat.png')
);
use Astaroth\VkUtils\Builders;
use Astaroth\VkUtils\Builders\Message;
use Astaroth\VkUtils\Builders\Post;
$token = 'PUT TOKEN';
$builder = new \Astaroth\VkUtils\Builder();
$builders[] = (new Message)
->setMessage("hi me name is lola! im lol")
->setPeerId(418618);
$builders[] = (new Post)
->setMessage("hello subscribers")
$response = $builder->create(...$builders)
);