labile/vk-data-fetcher

There is no license information available for the latest version (1.3.1) of this package.

vk callback\longpoll bots data fetcher

1.3.1 2021-09-01 22:00 UTC

This package is auto-updated.

Last update: 2024-11-09 15:08:24 UTC


README

GitHub license Packagist Stars Packagist Stats

Документация на русском языке

Installation

composer require labile/vk-data-fetcher

Data fetcher for bots vkontakte

<?php

declare(strict_types=1);

use Astaroth\DataFetcher\DataFetcher;

$input_data = json_decode("vk json object", false);

$data = new DataFetcher($input_data);

$raw_data = $data->getRawData();
//$raw_data->...

if ($data->getType() === "message_new"){
    $message_new = $data->messageNew();
    
    $message_new->getText();
    $message_new->getAttachments();
    $message_new->getFromId();
    $message_new->getPayload();
    //...
}

if ($data->getType() === "message_event"){
    $message_event = $data->messageEvent();

    $message_event->getConversationMessageId();
    $message_event->getPeerId();
    $message_event->getEventId();
    $message_event->getChatId();
    //...
}