PHP code example of olsgreen / adobe-sign-api

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

    

olsgreen / adobe-sign-api example snippets


// Create an instance of the client.
$api = new \Olsgreen\AdobeSign\Client($your_access_token, ['data_center' => 'us2']);

// Upload a document from a path
$transientDocumentId = $api->documents()->uploadFile('/path/to/my/file.pdf');

// Upload a stream, resource or binary data.
$data = fopen('/path/to/my/file.pdf', 'r');
$transientDocumentId = $api->documents()->upload('file.pdf', 'application/pdf', $data);

use \Olsgreen\AdobeSign\Api\Builders\Factory;
use \Olsgreen\AdobeSign\Api\Enums\SignatureTypes;
use \Olsgreen\AdobeSign\Api\Enums\AgreementStates;
use \Olsgreen\AdobeSign\Api\Enums\ParticipantRoles;
...

// Create the base agreement object.
$agreement = Factory::createAgreementInfoBuilder()
    ->setName('Test Agreement')
    ->setSignatureType(SignatureTypes::TYPE_ESIGN)
    ->setState(AgreementStates::IN_PROCESS);

// Add the PDF file for signing to the agreement using the 
// $transientDocumentId from the document upload example above.
$agreement->fileInfos()->add(
    Factory::createFileInfoBuilder()
        ->setLabel('Test File')
        ->setTransientDocumentId($transientDocumentId)
);

// Create a participant set for the signer.
$participantSetsInfo = Factory::createParticipantSetInfoBuilder()
    ->setOrder(1)
    ->setRole(ParticipantRoles::SIGNER);

// Add a participant to the set.
$participantSetsInfo->memberInfos()->add(
    Factory::createParticipantInfoBuilder()
        ->setEmail('[email protected]')
);

// Add the participant set to the agreement.
$agreement->participantSetsInfo()->add($participantSetsInfo);

// Create the agreement via the API.
$agreementId = $api->agreements()->create($agreement);

// Gets the signing URLs from the API.
$urls = $api->agreements()->getSigningUrls($agreementId);

// Will output similar to:
// [
//     ['email' => '[email protected]', 'esignUrl' => 'https://secure.adobesign.com/sign1'],
//     ['email' => '[email protected]', 'esignUrl' => 'https://secure.adobesign.com/sign2']
// ]

use \Olsgreen\AdobeSign\Api\Builders\WebhookInfoBuilder;
use \Olsgreen\AdobeSign\Api\Enums\WebhookScopes;
use \Olsgreen\AdobeSign\Api\Enums\WebhookEventNames;

...

$webhook = WebhookInfoBuilder::create()
    ->setName('Test Webhook')
    ->setScope(WebhookScopes::USER)
    ->setUrl('https://mydomain.com/hooks/adobe-sign')
    ->setWebhookSubscriptionEvents([
        WebhookEventNames::AGREEMENT_ALL
    ]);

$webhookId = $api->webhooks()->create($webhook);