PHP code example of guinee / eservice

1. Go to this page and download the library: Download guinee/eservice 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/ */

    

guinee / eservice example snippets


$client = new Client(Config::fromArray([
    'baseUrl' => getenv('ESERVICE_API_BASE'),
    'partnerId' => getenv('ESERVICE_PARTNER_ID'),
    'partnerSecret' => getenv('ESERVICE_PARTNER_SECRET'),
    'oauthTokenUrl' => getenv('ESERVICE_OAUTH_TOKEN_URL'),
    'oauthClientId' => getenv('ESERVICE_OAUTH_CLIENT_ID'),
    'oauthClientSecret' => getenv('ESERVICE_OAUTH_CLIENT_SECRET'),
    'oauthGrantType' => getenv('ESERVICE_OAUTH_GRANT_TYPE') ?: 'client_credentials',
    'verifySsl' => filter_var(getenv('ESERVICE_VERIFY_SSL') ?: 'true', FILTER_VALIDATE_BOOL),
    'caBundle' => getenv('ESERVICE_CA_BUNDLE') ?: null,
]));

$client->callback('DEM-2026-00042', CallbackRequest::completed(['numero' => 'REG-1']));

$reference = 'DEM-2026-00042';

$client->sendMessage($reference, 'Votre dossier est en cours de traitement.');
// Recommandé : le fichier est téléversé et conservé avec la demande (15 Mo max).
$client->sendDocument(
    $reference,
    [
        'file' => __DIR__ . '/decision.pdf',
        'filename' => 'decision.pdf',
        'title' => 'Décision',
        'numero' => 'REG-2026-001',
    ],
    'Voici votre document.',
);
// Toujours compatible : document déjà hébergé par le partenaire.
$client->sendDocument(
    $reference,
    ResultData::make()->numero('REG-2026-001')->documentUrl('https://…/doc.pdf'),
);
$client->requestDocuments($reference, ['CNI', 'Justificatif de domicile'], 'Merci de compléter.');
$client->validAppointment($reference, 'rdv', 'approve');
$client->completeDemand($reference, 'Votre demande est terminée.');

// Callback webhook (demande entière — plus lié à une étape)
$client->callback($reference, CallbackRequest::completed(['numero' => 'REG-1']));

use EService\Partner\Dossier\IncomingDossier;

$dossier = IncomingDossier::fromPayload(file_get_contents('php://input'));
$reference = $dossier->reference; // utiliser ensuite dans sendMessage / sendDocument / …

http_response_code(200);
header('Content-Type: application/json');
echo json_encode($dossier->ackResponse('JOB-' . uniqid(), 'accepted'));