Skip to content

retailcrm/mg-bot-api-client-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

46e0f84 · Nov 15, 2024
Dec 22, 2022
Jul 16, 2019
Nov 14, 2024
Aug 14, 2024
Jul 16, 2019
Aug 10, 2023
Dec 15, 2020
Aug 10, 2023
Aug 10, 2023
Aug 10, 2023
Oct 26, 2023
Dec 13, 2021
Dec 22, 2022
Jun 10, 2019

Repository files navigation

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();