PHP code example of business-ru / ofd-api-sdk-php

1. Go to this page and download the library: Download business-ru/ofd-api-sdk-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

business-ru / ofd-api-sdk-php example snippets


/**
* Инициализируем класс
* @var OfdClient|null
*/
private ?OfdClient $ofdClient = null;

/**
* Общий метод, для любой модели
* Метод позволяет выполнить запрос к API OFD
* Для ofd-api-sdk-php
* @param string $method - Наименование метода
* @param string $model - Наименование модели
* @param array<array> $params - Параметры запроса
* @return int|mixed|string[]
* @throws \JsonException
* @throws ClientExceptionInterface
* @throws DecodingExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function ofdApiRequest(string $method, string $model, array $params = [])
{
	$this->ofdClient = new OfdClient();
	$this->response = $this->ofdClient->request(strtoupper($method), $model, $params);
	return $this->response;
}

ini
OFD_TOKEN = Токен