2019-06-28 14:15:30 +03:00
[](https://travis-ci.org/retailcrm/mg-bot-api-client-php)
2019-07-16 15:04:54 +03:00
[](https://codecov.io/gh/retailcrm/mg-bot-api-client-php)
2019-06-28 14:15:30 +03:00
[](https://packagist.org/packages/retailcrm/mg-bot-api-client-php)
2019-07-16 15:04:54 +03:00
[](https://packagist.org/packages/retailcrm/mg-bot-api-client-php)
2019-06-28 14:15:30 +03:00
# retailCRM API PHP client
This is php retailCRM MG Bot API client.
## Requirements
2019-07-16 15:04:54 +03:00
* PHP 7.1 and above
2019-06-28 14:15:30 +03:00
* 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.0
```
If you have not used `composer` before, include autoloader into your project.
```php
require 'path/to/vendor/autoload.php';
```
## Usage
### Assign dialog
```php
2019-06-28 14:43:11 +03:00
use RetailCrm\Mg\Bot\Client;
use RetailCrm\Mg\Bot\Model\Request\DialogAssignRequest;
2019-06-28 14:15:30 +03:00
$client = new Client('https://mg.url.demo', 'T9DMPvuNt7FQJMszHUd', true);
try {
$request = new DialogAssignRequest();
$request->setDialogId(60);
$request->setUserId(4);
$response = $client->dialogAssign($request);
2019-06-28 14:25:03 +03:00
} catch (\RetailCrm\Common\Exception\CurlException $exception) {
2019-06-28 14:15:30 +03:00
echo $exception->getMessage();
2019-06-28 14:25:03 +03:00
} catch (\RetailCrm\Common\Exception\LimitException $exception) {
2019-06-28 14:15:30 +03:00
echo $exception->getMessage();
} catch (\InvalidArgumentException $exception) {
echo $exception->getMessage();
} catch (\Exception $exception) {
echo $exception->getMessage();
}
if ($response->isSuccessful()) {
$response->getPreviousResponsible();
}
```
### Documentation
2019-06-28 14:25:03 +03:00
* [English ](https://139810.selcdn.ru/download/doc/mg-bot-api/bot.v1.en.html )
* [Russian ](https://help.retailcrm.ru/Developers/MgBot )