PHP code example of kgilden / php-digidoc
1. Go to this page and download the library: Download kgilden/php-digidoc 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/ */
kgilden / php-digidoc example snippets
use KG\DigiDoc\Api;
use KG\DigiDoc\Client;
// This file is generated by Composer
api->create();
// Add the files you want to get signed.
$envelope->addFile('/path/to/file.txt');
$envelope->addFile('/second/path/to/file.md');
// Add a signature or two. Signature takes in certificate id and certificate
// signature. You must retrieve these from the client using the browser plugin.
$envelope->addSignature($signature = new Signature('F1..20', '8F..C0'));
// Sync up with the server. For example, the previous signature is given
// a challenge, which the client must solve.
$api->update($envelope);
printf("Challenge: %s\n", $signature->getChallenge());
// Set the solution for the given signature. This is computed by the borwser
// plugin.
$signature->setSolution('F6..00');
// Sync up with the server once more to send the solution.
$api->update($envelope);
// Time to write it on the disc.
$api->write('/tmp/my-newly-created-envelope.bdoc');
// Make sure to "close" the envelope (basically closes the session in the
// remote DigiDoc service).
$api->close($envelope);