PHP code example of signnow / api-php-sdk

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

    

signnow / api-php-sdk example snippets




use SignNow\ApiClient;
use SignNow\Api\Document\Request\DocumentGet;
use SignNow\Exception\SignNowApiException;
use SignNow\Sdk;

$sdk = new Sdk();

try {
    // Method authenticate() will use the credentials from the .env file
    // and create a new bearer token for further requests
    $apiClient = $sdk->build()
        ->authenticate()
        ->getApiClient();
    // Now, you are ready to use the API client to send requests

    // if you want to keep the token, you can use the following code
    $bearerToken = $sdk->actualBearerToken();
    // or
    $bearerToken = $apiClient->getBearerToken();
} catch (SignNowApiException $e) {
    echo $e->getMessage();
}



use SignNow\ApiClient;
use SignNow\Api\Document\Request\DocumentGet;
use SignNow\Core\Token\BearerToken;
use SignNow\Exception\SignNowApiException;
use SignNow\Sdk;

$sdk = new Sdk();

try {
    $token = 'YOUR_TOKEN_HERE';
    $apiClient = $sdk->build()
        ->withBearerToken(new BearerToken($token, '', 0))
        ->getApiClient();
    // Now, you are ready to use the API client to send requests
} catch (SignNowApiException $e) {
    echo $e->getMessage();
}



use SignNow\ApiClient;
use SignNow\Api\Document\Request\DocumentGet;
use SignNow\Exception\SignNowApiException;
use SignNow\Sdk;

$sdk = new Sdk();

try {
    // Instantiate the API client
    $apiClient = $sdk->build()
        ->authenticate()
        ->getApiClient();

    // Prepare a request to get a document by id
    $documentId = 'e896ec9311a74a8a8ee9faff7049446fe452e461';
    $request = new DocumentGet();
    $request->withDocumentId($documentId);

    // Send the request and get the response
    $response = $apiClient->send($request);
} catch (SignNowApiException $e) {
    echo $e->getMessage();
}
bash
composer