1. Go to this page and download the library: Download itechsection/salesprosdk 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/ */
// Create
$tokenData = $client->auth->createPersonalAccessToken('my-app', ['*']);
echo $tokenData['accessToken']; // save this — shown only once
// List
$tokens = $client->auth->listPersonalAccessTokens();
// Delete
$client->auth->deletePersonalAccessToken($tokenData['id']);
$result = $client->contacts->list(['page' => 1, 'per_page' => 15]);
echo $result->total(); // total records
echo $result->meta->lastPage; // last page number
echo $result->meta->currentPage;
if ($result->hasMorePages()) {
$page2 = $client->contacts->list(['page' => 2, 'per_page' => 15]);
}
// Or fetch ALL pages automatically:
$allContacts = $client->httpClient->getAllPages('connector/api/contactapi');
use ITechSection\SalesPro\Exceptions\AuthenticationException;
use ITechSection\SalesPro\Exceptions\AuthorizationException;
use ITechSection\SalesPro\Exceptions\NotFoundException;
use ITechSection\SalesPro\Exceptions\ValidationException;
use ITechSection\SalesPro\Exceptions\RateLimitException;
use ITechSection\SalesPro\Exceptions\ServerException;
use ITechSection\SalesPro\Exceptions\NetworkException;
use ITechSection\SalesPro\Exceptions\SalesProException;
try {
$result = $client->contacts->create($data);
} catch (ValidationException $e) {
// Field-level validation failures (HTTP 422)
foreach ($e->getErrors() as $field => $messages) {
echo "{$field}: " . implode(', ', $messages) . "\n";
}
} catch (AuthenticationException $e) {
// 401 — credentials invalid or token expired
echo "Auth error: {$e->getMessage()}\n";
} catch (NotFoundException $e) {
// 404
echo "Not found: {$e->getMessage()}\n";
} catch (RateLimitException $e) {
// 429
echo "Rate limited. Retry after {$e->getRetryAfter()} seconds.\n";
} catch (ServerException $e) {
// 5xx
echo "Server error ({$e->getCode()}): {$e->getMessage()}\n";
} catch (NetworkException $e) {
// DNS / timeout / connection refused
echo "Network error: {$e->getMessage()}\n";
} catch (SalesProException $e) {
// Any other SDK error
echo "SDK error: {$e->getMessage()}\n";
}
bash
# Copy the library
cp vendor/itechsection/salesprosdk/src/CodeIgniter3/Salespro.php \
application/libraries/Salespro.php
# Copy the config stub
cp vendor/itechsection/salesprosdk/src/CodeIgniter3/config/salesproconf.php \
application/config/salespro.php