54 lines
1.7 KiB
Markdown
54 lines
1.7 KiB
Markdown
[![Build Status](https://github.com/retailcrm/mg-bot-api-client-php/workflows/ci/badge.svg)](https://github.com/retailcrm/mg-bot-api-client-php/actions)
|
|
[![Coverage](https://img.shields.io/codecov/c/gh/retailcrm/mg-bot-api-client-php/master.svg?logo=codecov&logoColor=white)](https://codecov.io/gh/retailcrm/mg-bot-api-client-php)
|
|
[![Latest stable](https://img.shields.io/packagist/v/retailcrm/mg-bot-api-client-php.svg)](https://packagist.org/packages/retailcrm/mg-bot-api-client-php)
|
|
[![PHP from Packagist](https://img.shields.io/packagist/php-v/retailcrm/mg-bot-api-client-php.svg?logo=php&logoColor=white)](https://packagist.org/packages/retailcrm/mg-bot-api-client-php)
|
|
|
|
|
|
# Message Gateway Bot API PHP client
|
|
|
|
## Requirements
|
|
|
|
* PHP 7.3 and above
|
|
* PHP's cURL support
|
|
* PHP's JSON support
|
|
|
|
## Install
|
|
|
|
1) Get [composer](https://getcomposer.org/download/)
|
|
|
|
2) Run into your project directory:
|
|
```bash
|
|
composer require retailcrm/mg-bot-api-client-php ~1.*
|
|
```
|
|
|
|
If you have not used `composer` before, include autoloader into your project.
|
|
```php
|
|
require 'path/to/vendor/autoload.php';
|
|
```
|
|
|
|
## Usage
|
|
|
|
### Assign dialog
|
|
```php
|
|
<?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();
|
|
```
|