PHP code example of kruegge82 / deutschepost-internetmarke-php-sdk

1. Go to this page and download the library: Download kruegge82/deutschepost-internetmarke-php-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/ */

    

kruegge82 / deutschepost-internetmarke-php-sdk example snippets





apiInstance = new OpenAPI\Client\Api\ApiVersionResourceApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client()
);

try {
    $result = $apiInstance->apiVersion();
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling ApiVersionResourceApi->apiVersion: ', $e->getMessage(), PHP_EOL;
}



Instance = new OpenAPI\Client\Api\UserResourceApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client()
);
$grant_type = 'client_credentials'; // string | OAuth2 standard content, must be set to 'client_credentials'
$username = '[email protected]'; // string | Internetmarke user name (e.g. 'franz.klammer').
$password = 'abfahrt123#'; // string | Internetmarke password (e.g. 'abfahrt123#')
$client_id = 'XjSnyVWgQp1ShIQ5HQ6Vq5PIYLN2jGNS'; // string | API client_id obtained from developer portal (e.g. 'XjSnyVWgQp1ShIQ5HQ6Vq5PIYLN2jGNS')
$client_secret = 'TICgJWGRysH7mA57'; // string | API client_secret obtained from developer portal (e.g. 'TICgJWGRysH7mA57')
$for_payment = false; // bool | Flag to indicate the authorization for payment use case.


try {
    $result = $apiInstance->authorization($grant_type, $username, $password, $client_id, $client_secret, $for_payment);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling UserResourceApi->authorization: ', $e->getMessage(), PHP_EOL;
}

// Configure Bearer authorization: BearerAuth
$config = OpenAPI\Client\Configuration::getDefaultConfiguration()->setAccessToken($result->getAccessToken());

$apiInstance = new OpenAPI\Client\Api\AppResourceApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client(),
    $config
);

$AppShoppingCartPDFPosition=new \OpenAPI\Client\Model\AppShoppingCartPDFPosition();
$AppShoppingCartPDFPosition->setProductCode(10001);
$AppShoppingCartPDFPosition->setVoucherLayout("ADDRESS_ZONE");
$position = new \OpenAPI\Client\Model\VoucherPosition();
$position->setPage(1);
$position->setLabelX(1);
$position->setLabelY(1);
$AppShoppingCartPDFPosition->setPosition($position);
$AppShoppingCartPDFPosition->setPositionType("AppShoppingCartPDFPosition");

$checkout_shopping_cart_pdf_app_request = new \OpenAPI\Client\Model\AppShoppingCartPDFRequest();
$checkout_shopping_cart_pdf_app_request->setType('AppShoppingCartPDFRequest');
$checkout_shopping_cart_pdf_app_request->setPageFormatId(2);
//$checkout_shopping_cart_pdf_app_request->setShopOrderId($result->getShopOrderId());
$checkout_shopping_cart_pdf_app_request->setPositions($AppShoppingCartPDFPosition);
$checkout_shopping_cart_pdf_app_request->setTotal(110);
//$checkout_shopping_cart_pdf_app_request->setCreateManifest(false);
//$checkout_shopping_cart_pdf_app_request->setCreateShippingList(false);
$checkout_shopping_cart_pdf_app_request->setDpi('DPI203');
$validate = false; // bool | This request parameter enables the validate (preview) case.<br/>The response will contain the link to a preview image of an internet stamp in PDF format. A product code, a layout format and optionally a motif are transferred to the service. This information is encoded in the link and evaluated by INTERNETMARKE when the preview image is rendered. If the product code, print format, or theme ID is invalid, the response to the caller will contain appropriate information.   <br/><br/> For the validate (preview) case the 'Authorization' header is not 
json
{
  "repositories": [
    {
      "type": "vcs",
      "url": "https://github.com/kruegge82/deutschepost-internetmarke-php-sdk.git"
    }
  ],
  "