PHP client for MG Bot API
extra | ||
src | ||
tests | ||
.env.dist | ||
.gitignore | ||
.travis.yml | ||
composer.json | ||
composer.lock | ||
LICENSE | ||
Makefile | ||
phpstan.neon | ||
phpunit.xml.dist | ||
phpunit.xsd | ||
README.md |
retailCRM API PHP client
This is php retailCRM MG Bot API client.
Requirements
- PHP 7.0 and above
- PHP's cURL support
- PHP's JSON support
Install
-
Get composer
-
Run into your project directory:
composer require retailcrm/mg-bot-api-client-php ~1.0
If you have not used composer
before, include autoloader into your project.
require 'path/to/vendor/autoload.php';
Usage
Assign dialog
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);
$response = $client->dialogAssign($request);
} catch (\RetailCrm\Common\Exception\CurlException $exception) {
echo $exception->getMessage();
} catch (\RetailCrm\Common\Exception\LimitException $exception) {
echo $exception->getMessage();
} catch (\InvalidArgumentException $exception) {
echo $exception->getMessage();
} catch (\Exception $exception) {
echo $exception->getMessage();
}
if ($response->isSuccessful()) {
$response->getPreviousResponsible();
}