1
0
mirror of synced 2024-11-21 19:36:02 +03:00
PHP client for MG Bot API
Go to file
2024-06-24 20:21:41 +03:00
.github/workflows update test matrix 2022-12-22 14:57:29 +03:00
extra Update models & serialization (#3) 2019-07-16 15:04:54 +03:00
src Add templates interaction 2024-06-24 20:21:41 +03:00
tests Add templates interaction 2024-06-24 20:21:41 +03:00
.env.dist Update models & serialization (#3) 2019-07-16 15:04:54 +03:00
.gitignore Ability to run tests in docker 2023-08-10 18:40:29 +03:00
composer.json Actualized PHP version in README and composer.json according to the versions in CI 2023-08-10 18:31:31 +03:00
LICENSE Update product name, cleanup annotations (#14) 2020-12-15 13:34:43 +03:00
Makefile Ability to run tests in docker 2023-08-10 18:40:29 +03:00
phpstan-baseline.neon update phpstan baseline 2023-10-26 10:13:42 +03:00
phpstan.neon Update php version (#20) 2021-12-13 10:48:18 +03:00
phpunit.xml.dist update dependencies 2022-12-22 14:55:13 +03:00
phpunit.xsd Initial version (#1) 2019-06-10 16:24:22 +03:00
README.md Actualized PHP version in README and composer.json according to the versions in CI 2023-08-10 18:31:31 +03:00

Build Status Coverage Latest stable PHP from Packagist

Message Gateway Bot API PHP client

Requirements

  • PHP 7.3 and above
  • PHP's cURL support
  • PHP's JSON support

Install

  1. Get composer

  2. Run into your project directory:

composer require retailcrm/mg-bot-api-client-php ~1.*

If you have not used composer before, include autoloader into your project.

require 'path/to/vendor/autoload.php';

Usage

Assign dialog

<?php

use RetailCrm\Common\Exception;
use RetailCrm\Mg\Bot\Client;
use RetailCrm\Mg\Bot\Model\Request\DialogAssignRequest;

$client = new Client('https://mg.url.demo', 'T9DMPvuNt7FQJMszHUd', true);

try {
    $request = new DialogAssignRequest();
    $request->setDialogId(60);
    $request->setUserId(4);

    /* @var \RetailCrm\Mg\Bot\Model\Response\AssignResponse $response */
    $response = $client->dialogAssign($request);
} catch (Exception\LimitException | Exception\InvalidJsonException | Exception\UnauthorizedException $exception) {
    echo $exception->getMessage();
}

echo $response->getPreviousResponsible();