PHP code example of espocrm / php-espo-api-client
1. Go to this page and download the library: Download espocrm/php-espo-api-client 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/ */
espocrm / php-espo-api-client example snippets
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.
}
composer