PHP code example of dfridrich / czech-data-box

1. Go to this page and download the library: Download dfridrich/czech-data-box 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/ */

    

dfridrich / czech-data-box example snippets




$dataBox->DmOperationsWebService();
$dataBox->DmInfoWebService();
$dataBox->DataBoxSearch();
$dataBox->DataBoxAccess();
$dataBox->IsdsStat();



efr\CzechDataBox\DataBox;

$dataBox = new DataBox();
$dataBox->loginWithUsernameAndPassword("login", "heslo", true); // Pro ostrou verzi
$dataBox->loginWithUsernameAndPassword("login", "heslo", false); // Pro verzi s testovacím přístupem
$dataBox->loginWithCertificateAndPassword("certifikat.cer"); // Nebo pouzijte prihlaseni certifikatem

/** @var \Defr\CzechDataBox\DataBoxSimpleApi $simpleApi */
$simpleApi = $dataBox->getSimpleApi();

$simpleApi->getDataBoxInfo(); // vrací Defr\CzechDataBox\Api\tDbOwnerInfo

$simpleApi->getUserInfo(); // Vrací Defr\CzechDataBox\Api\tDbUserInfo;

$simpleApi->getPasswordExpires(); // \DateTime|null

$days = 90;
$limit = 1000;

$messages = $simpleApi->getListOfReceivedMessages($days, $limit);
foreach ($messages as $message) {
    echo "<h2>Msg# " . $message->getDmID() . "</h2>";
    // Defr\CzechDataBox\Api\tIdDm
    var_dump($message);

    echo "<h3>Signed message</h3>";
    // Defr\CzechDataBox\DataBoxMessageFile
    var_dump($simpleApi->downloadSignedReceivedMessage($message->getDmID()));

    echo "<h3>Delivery info</h3>";
    // Defr\CzechDataBox\DataBoxMessageFile
    var_dump($simpleApi->downloadDeliveryInfo($message->getDmID()));

    echo "<h3>Attachments</h3>";
    // Defr\CzechDataBox\DataBoxMessageAttachment[]
    var_dump($simpleApi->getReceivedDataMessageAttachments($message->getDmID()));
}

$messages = $simpleApi->getListOfSentMessages();
foreach ($messages as $message) {
    echo "<h2>Msg# " . $message->getDmID() . "</h2>";
    var_dump($message);

    echo "<h3>Signed message</h3>";
    var_dump($simpleApi->downloadSignedSentMessage($message->getDmID()));

    echo "<h3>Delivery info</h3>";
    var_dump($simpleApi->downloadDeliveryInfo($message->getDmID()));
}


$simpleApi->findDataBoxById('wucb4dd');

$files = [
    '/path/to/a/file.pdf',
];
$message = $simpleApi->createBasicDataMessage('wucb4dd', 'Test', $files);
$sentMessage = $simpleApi->sendDataMessage($message);
if ($sentMessage->getDmStatus()->getDmStatusCode() !== "0000") {
    // Handle errors
}