2014-11-06 02:44:52 +03:00
|
|
|
PHP client for retailCRM API
|
2013-07-04 10:18:28 +04:00
|
|
|
=================
|
2013-07-02 12:37:54 +04:00
|
|
|
|
2014-11-06 02:44:52 +03:00
|
|
|
PHP client for [retailCRM API](http://www.retailcrm.ru/docs/Разработчики/Разработчики#api).
|
2013-07-03 18:13:25 +04:00
|
|
|
|
2013-07-04 12:44:41 +04:00
|
|
|
Requirements
|
|
|
|
------------
|
2013-07-03 18:13:25 +04:00
|
|
|
|
2013-10-08 11:19:50 +04:00
|
|
|
* PHP version 5.3 and above
|
2013-07-03 18:13:25 +04:00
|
|
|
* PHP-extension CURL
|
2013-07-04 12:44:41 +04:00
|
|
|
|
|
|
|
Installation
|
|
|
|
------------
|
|
|
|
|
2014-04-21 14:56:52 +04:00
|
|
|
1) Install [composer](https://getcomposer.org/download/) into the project directory.
|
2013-07-04 12:44:41 +04:00
|
|
|
|
2014-11-06 02:44:52 +03:00
|
|
|
2) Run:
|
|
|
|
```bash
|
|
|
|
composer require retailcrm/api-client-php 3.0
|
2013-10-08 11:19:38 +04:00
|
|
|
```
|
2014-11-06 02:55:09 +03:00
|
|
|
|
|
|
|
Usage
|
|
|
|
-----
|
|
|
|
|
2014-11-06 03:18:39 +03:00
|
|
|
Example of the receipt of order:
|
2014-11-06 02:55:09 +03:00
|
|
|
```php
|
|
|
|
|
|
|
|
$client = new \RetailCrm\ApiClient(
|
|
|
|
'https://demo.intarocrm.ru',
|
|
|
|
'T9DMPvuNt7FQJMszHUdG8Fkt6xHsqngH'
|
|
|
|
);
|
|
|
|
|
|
|
|
try {
|
|
|
|
$response = $client->ordersGet('M-2342');
|
|
|
|
} catch (\RetailCrm\Exception\CurlException $e) {
|
|
|
|
echo "CRM connection error: " . $e->getMessage();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($response->isSuccessful()) {
|
|
|
|
echo $response->order['totalSumm'];
|
|
|
|
// or $response['order']['totalSumm'];
|
|
|
|
// or
|
|
|
|
// $order = $response->getOrder();
|
|
|
|
// $order['totalSumm'];
|
|
|
|
}
|
2014-11-06 03:18:39 +03:00
|
|
|
```
|
|
|
|
|
|
|
|
Example of the order creating:
|
|
|
|
```php
|
|
|
|
|
|
|
|
$client = new \RetailCrm\ApiClient(
|
|
|
|
'https://demo.intarocrm.ru',
|
|
|
|
'T9DMPvuNt7FQJMszHUdG8Fkt6xHsqngH'
|
|
|
|
);
|
|
|
|
|
|
|
|
try {
|
|
|
|
$response = $client->ordersCreate(array(
|
|
|
|
'externalId' => 'some-shop-order-id',
|
|
|
|
'firstName' => 'Vasily',
|
|
|
|
'lastName' => 'Pupkin',
|
|
|
|
'items' => array(
|
|
|
|
//...
|
|
|
|
),
|
|
|
|
delivery => array(
|
|
|
|
'code' => 'russian-post',
|
|
|
|
)
|
|
|
|
));
|
|
|
|
} catch (\RetailCrm\Exception\CurlException $e) {
|
|
|
|
echo "CRM connection error: " . $e->getMessage();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($response->isSuccessful() && 201 === $response->getStatusCode()) {
|
|
|
|
echo 'Order created successfully! Order ID in CRM - ' . $response->id;
|
|
|
|
// or $response['id'];
|
|
|
|
// or $response->getId();
|
|
|
|
}
|
2014-11-06 02:55:09 +03:00
|
|
|
```
|