business-ru / ofd-api-sdk-php
用于操作 OFD API 的 SDK
1.0.2
2023-04-17 16:49 UTC
Requires
- php: >=7.4
- ext-curl: *
- ext-json: *
- monolog/monolog: ^2.6
- psr/log: ^1.0
- psr/simple-cache: ^1.0
- symfony/http-client: ^5.3
This package is auto-updated.
Last update: 2024-09-11 13:40:03 UTC
README
项目信息
该库旨在用于与 ОФД-Я 服务交互。
要求
- PHP 7.4 及以上
- PHP 扩展 cURL
安装
composer require business-ru/ofd-api-sdk-php
文档:[https://ofd-ya.ru/docs/API_OFD_YA.pdf](https://ofd-ya.ru/docs/API_OFD_YA.pdf)
使用
添加到 .env
OFD_TOKEN = Токен
使用示例
/** * Инициализируем класс * @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; }
基本术语
表格中列出的术语按易于理解的方式排序。