PHP code example of erecht24 / rechtstexte-sdk

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

    

erecht24 / rechtstexte-sdk example snippets


switch ($type) {
    case Helper::PUSH_TYPE_IMPRINT:
    case Helper::PUSH_TYPE_PRIVACY_POLICY:
    case Helper::PUSH_TYPE_PRIVACY_POLICY_SOCIAL_MEDIA:
        $legalTextHandler = new LegalTextHandler('YOUR_API_KEY', $type, 'YOUR-PLUGIN-KEY');
        /* @var LegalText $legalText */
        $legalTextDoc = $legalTextHandler->importDocument();
        $legalText = $legalTextDoc->getHtmlDE();
{ ... }

if ($imprint = $apiHandler->getImprint()) {
    $html = $imprint->getHtmlDE();
}

if ($imprint = $apiHandler->getImprint()) {
    $html = $imprint->getHtml('en');
}

// new client data
$newClient = (new Client())
    ->setPushMethod('POST')
    ->setPushUri('https://test.de/push')
    ->setCms('WP')
    ->setCmsVersion('8.0')
    ->setPluginName('erecht24/rechtstexte-wp')
    ->setAuthorMail('[email protected]');

//  e eRecht24\RechtstexteSDK\ApiHandler;
use eRecht24\RechtstexteSDK\Model\Client;
use eRecht24\RechtstexteSDK\Exceptions\Exception;

// initialize api handler
$apiHandler = new ApiHandler('YOUR-API-KEY', 'YOUR-PLUGIN-KEY');

// the new client data
$newClient = (new Client())
    ->setPushMethod('POST')
    ->setPushUri('https://test.de/push')
    ->setCms('WP')
    ->setCmsVersion('8.0')
    ->setPluginName('erecht24/rechtstexte-wp')
    ->setAuthorMail('[email protected]');

try {
    // create the new client
    $client = $apiHandler->createClient($newClient);

    if (!$apiHandler->isLastResponseSuccess()) {
        // do stuff in case of an error
    }

    if ($imprint = $apiHandler->getImprint()) {
        // example: get DE imprint
        $html = $imprint->getHtmlDE();
    }

} catch (Exception $e) {
    // as you need, log or rethrow here
}

// now go on with whatever service you want to execute