espocrm / php-espo-api-client
EspoCRM 的 API 客户端。
0.1.1
2024-04-08 13:19 UTC
Requires
- php: >=8.0.0
- ext-curl: *
Requires (Dev)
- phpstan/phpstan: ^1.9
- phpunit/phpunit: ^9.5
This package is not auto-updated.
Last update: 2024-09-23 16:16:38 UTC
README
使用 Composer 安装
composer require espocrm/php-espo-api-client
用法
use Espo\ApiClient\Client; use Espo\ApiClient\Header; use Espo\ApiClient\Exception\ResponseError; $client = new Client($yourEspoUrl); $client->setApiKey($apiKey); $client->setSecretKey($secretKey); // if you use HMAC method try { $response = $client->request( Client::METHOD_POST, 'Lead', [ 'firstName' => $firstName, 'lastName' => $lastName, 'emailAddress' => $emailAddress, ], [new Header('X-Skip-Duplicate-Check', 'true')] ); $parsedBody = $response->getParsedBody(); } catch (ResponseError $e) { // Error response. $response = $e->getResponse(); $code = $response->getCode(); $body = $response->getBodyPart(); // Consider using some additional library if you need parsed response headers. }