PHP code example of everbinding / econnect-psb-php

1. Go to this page and download the library: Download everbinding/econnect-psb-php 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/ */

    

everbinding / econnect-psb-php example snippets




$config = \EConnect\Psb\Configuration::getDefaultConfiguration();

$config
    ->setUsername("{username}")
    ->setPassword("{password}");
    ->setClientId("{clientId}")
    ->setClientSecret("{clientSecret}")
    ->setHost("https://psb.econnect.eu")
    ->setApiKey('Subscription-Key', '{subscription key}');

$config = \EConnect\Psb\Configuration::getDefaultConfiguration();

$authN = new \EConnect\Psb\Authentication($config);
$authN->login();

$config = \EConnect\Psb\Configuration::getDefaultConfiguration();

$salesInvoiceApi = new EConnect\Psb\Api\SalesInvoiceApi(
    new GuzzleHttp\Client();
    $config
);

$yourPartyId = "senderPartyId";
$filePath = "./Ubl.xml";
$receiverPartyId = null;

$salesInvoiceApi->sendSalesInvoice($yourPartyId, $filePath, $receiverPartyId);

use Jumbojett\OpenIDConnectClient;

$oidc = new OpenIDConnectClient('https://identity.econnect.eu',
                                '{clientId}',
                                '{clientSecret}');

$oidc->addScope('ap');

// Add username and password
$oidc->addAuthParam(array('username'=>'{username}'));
$oidc->addAuthParam(array('password'=>'{password}'));

// to validate the JWT and whether the acces_token property is present
$token = $oidc->requestResourceOwnerToken(TRUE)->access_token;