Latest commit

History

98 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

The Official DocuSign PHP Client

Build status

You can sign up for a free developer sandbox.

Requirements

PHP 5.4+ or higher [http://www.php.net/].

Installation

Composer

You can install the bindings via Composer. Run the following command:

composer require docusign/esign-client

To use the bindings, use Composer's autoload:

require_once('vendor/autoload.php');

Manual Install

If you do not wish to use Composer, you can download the latest release. Then, to use the bindings, include the init.php file.

require_once('/path/to/docusign-esign-client/autoload.php');

Dependencies

This client has the following external dependencies:

Usage

To login and send a signature request from a template:

<?phprequire_once('docusign-php-client/autoload.php');
class DocuSignSample
{
publicfunctionsignatureRequestFromTemplate()
{
$username = "[EMAIL]";
$password = "[PASSWORD]";
$integrator_key = "[INTEGRATOR_KEY]"; // change to production (www.docusign.net) before going live$host = "https://demo.docusign.net/restapi";
// create configuration object and configure custom auth header$config = newDocuSign\eSign\Configuration();
$config->setHost($host);
$config->addDefaultHeader("X-DocuSign-Authentication", "{\"Username\":\"" . $username . "\",\"Password\":\"" . $password . "\",\"IntegratorKey\":\"" . $integrator_key . "\"}");
// instantiate a new docusign api client$apiClient = newDocuSign\eSign\ApiClient($config);
$accountId = null;
try {
//*** STEP 1 - Login API: get first Account ID and baseURL$authenticationApi = newDocuSign\eSign\Api\AuthenticationApi($apiClient);
$options = new \DocuSign\eSign\Api\AuthenticationApi\LoginOptions();
$loginInformation = $authenticationApi->login($options);
if(isset($loginInformation) && count($loginInformation) > 0)
{
$loginAccount = $loginInformation->getLoginAccounts()[0];
$host = $loginAccount->getBaseUrl();
$host = explode("/v2",$host);
$host = $host[0];
// UPDATE configuration object$config->setHost($host);
// instantiate a NEW docusign api client (that has the correct baseUrl/host)$apiClient = newDocuSign\eSign\ApiClient($config);
if(isset($loginInformation))
{
$accountId = $loginAccount->getAccountId();
if(!empty($accountId))
{
//*** STEP 2 - Signature Request from a Template// create envelope call is available in the EnvelopesApi$envelopeApi = newDocuSign\eSign\Api\EnvelopesApi($apiClient);
// assign recipient to template role by setting name, email, and role name. Note that the// template role name must match the placeholder role name saved in your account template.$templateRole = newDocuSign\eSign\Model\TemplateRole();
$templateRole->setEmail("[SIGNER_EMAIL]");
$templateRole->setName("[SIGNER_NAME]");
$templateRole->setRoleName("[ROLE_NAME]"); // instantiate a new envelope object and configure settings$envelop_definition = newDocuSign\eSign\Model\EnvelopeDefinition();
$envelop_definition->setEmailSubject("[DocuSign PHP SDK] - Signature Request Sample");
$envelop_definition->setTemplateId("[TEMPLATE_ID]");
$envelop_definition->setTemplateRoles(array($templateRole));
// set envelope status to "sent" to immediately send the signature request$envelop_definition->setStatus("sent");
// optional envelope parameters$options = new \DocuSign\eSign\Api\EnvelopesApi\CreateEnvelopeOptions();
$options->setCdseMode(null);
$options->setMergeRolesOnDraft(null);
// create and send the envelope (aka signature request)$envelop_summary = $envelopeApi->createEnvelope($accountId, $envelop_definition, $options);
if(!empty($envelop_summary))
{
echo"$envelop_summary";
}
}
}
}
}
catch (DocuSign\eSign\ApiException$ex)
{
echo"Exception: " . $ex->getMessage() . "\n";
}
}
}
?>

See UnitTests.php for more examples.

Authentication

Service Integrations that use Legacy Header Authentication

(Legacy Header Authentication uses the X-DocuSign-Authentication header.)

  1. Use the Authentication: login method to retrieve the account number and the baseUrl for the account. The url for the login method is www.docusign.net for production and demo.docusign.net for the developer sandbox. The baseUrl field is part of the loginAccount object. See the docs and the loginAccount object
  2. The baseUrl for the selected account, in production, will start with na1, na2, na3, eu1, or something else. Use the baseUrl that is returned to create the basePath (see the next step.) Use the basePath for all of your subsequent API calls.
  3. As returned by login method, the baseUrl includes the API version and account id. Split the string to obtain the basePath, just the server name and api name. Eg, you will receive https://na1.docusign.net/restapi/v2/accounts/123123123. You want just https://na1.docusign.net/restapi
  4. Instantiate the SDK using the basePath. Eg ApiClient apiClient = new ApiClient(basePath);
  5. Set the authentication header as shown in the examples by using Configuration.Default.AddDefaultHeader

User Applications that use OAuth Authentication

  1. After obtaining a Bearer token, call the OAuth: Userinfo method. Obtain the selected account's base_uri (server name) field. The url for the Userinfo method is account-d.docusign.com for the demo/developer environment, and account.docusign.com for the production environment.
  2. Combine the base_uri with "/restapi" to create the basePath. The base_uri will start with na1, na2, na3, eu1, or something else. Use the basePath for your subsequent API calls.
  3. Instantiate the SDK using the basePath. Eg ApiClient apiClient = new ApiClient(basePath);
  4. Create the authentication_value by combining the token_type and access_token fields you receive from either an Authorization Code Grant or Implicit Grant OAuth flow.
  5. Set the authentication header by using Configuration.Default.AddDefaultHeader('Authorization', authentication_value)

Testing

Unit tests are available in the test folder.

Follow the steps below to run the test cases

  • Rename the "TestConfig.php-sample" to "TestConfig.php"

  • Populate all the required values like the login credentials, integrator key, host, etc in TestConfig.php

  • Run the following command from the test folder

     phpunit.phar UnitTests.php
    

Support

Feel free to log issues against this client through GitHub. We also have an active developer community on Stack Overflow, search the DocuSignAPI tag.

License

The DocuSign PHP Client is licensed under the following License.

Notes

This version of the client library does not implement all of the DocuSign REST API methods. The current client omits methods in the Accounts, Billing, Cloud Storage, Connect, Groups (Branding), and Templates (Bulk Recipients) categories. The client's methods support the core set of use cases that most integrations will encounter. For a complete list of omitted endpoints, see Omitted Endpoints.

About

The Official DocuSign PHP Client Library used to interact with the eSign REST API. Send, sign, and approve documents using this client.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Add copy buttons to all
 blocks
(function() {
function addCopyButtons() {
document.querySelectorAll('pre code').forEach(function(codeBlock) {
if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;
codeBlock.parentElement.setAttribute('data-copy-added', 'true');
var btn = document.createElement('button');
btn.textContent = 'Copy';
btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';
btn.onmouseover = function() { this.style.opacity = '1'; };
btn.onmouseout = function() { this.style.opacity = '0.7'; };
btn.onclick = function() {
navigator.clipboard.writeText(codeBlock.textContent).then(function() {
btn.textContent = 'Copied!';
setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
});
};
codeBlock.parentElement.style.position = 'relative';
codeBlock.parentElement.appendChild(btn);
});
}
addCopyButtons();
// Re-run on dynamic content
var observer = new MutationObserver(addCopyButtons);
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

Latest commit

History

98 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

The Official DocuSign PHP Client

Build status

You can sign up for a free developer sandbox.

Requirements

PHP 5.4+ or higher [http://www.php.net/].

Installation

Composer

You can install the bindings via Composer. Run the following command:

composer require docusign/esign-client

To use the bindings, use Composer's autoload:

require_once('vendor/autoload.php');

Manual Install

If you do not wish to use Composer, you can download the latest release. Then, to use the bindings, include the init.php file.

require_once('/path/to/docusign-esign-client/autoload.php');

Dependencies

This client has the following external dependencies:

Usage

To login and send a signature request from a template:

<?phprequire_once('docusign-php-client/autoload.php');
class DocuSignSample
{
publicfunctionsignatureRequestFromTemplate()
{
$username = "[EMAIL]";
$password = "[PASSWORD]";
$integrator_key = "[INTEGRATOR_KEY]"; // change to production (www.docusign.net) before going live$host = "https://demo.docusign.net/restapi";
// create configuration object and configure custom auth header$config = newDocuSign\eSign\Configuration();
$config->setHost($host);
$config->addDefaultHeader("X-DocuSign-Authentication", "{\"Username\":\"" . $username . "\",\"Password\":\"" . $password . "\",\"IntegratorKey\":\"" . $integrator_key . "\"}");
// instantiate a new docusign api client$apiClient = newDocuSign\eSign\ApiClient($config);
$accountId = null;
try {
//*** STEP 1 - Login API: get first Account ID and baseURL$authenticationApi = newDocuSign\eSign\Api\AuthenticationApi($apiClient);
$options = new \DocuSign\eSign\Api\AuthenticationApi\LoginOptions();
$loginInformation = $authenticationApi->login($options);
if(isset($loginInformation) && count($loginInformation) > 0)
{
$loginAccount = $loginInformation->getLoginAccounts()[0];
$host = $loginAccount->getBaseUrl();
$host = explode("/v2",$host);
$host = $host[0];
// UPDATE configuration object$config->setHost($host);
// instantiate a NEW docusign api client (that has the correct baseUrl/host)$apiClient = newDocuSign\eSign\ApiClient($config);
if(isset($loginInformation))
{
$accountId = $loginAccount->getAccountId();
if(!empty($accountId))
{
//*** STEP 2 - Signature Request from a Template// create envelope call is available in the EnvelopesApi$envelopeApi = newDocuSign\eSign\Api\EnvelopesApi($apiClient);
// assign recipient to template role by setting name, email, and role name. Note that the// template role name must match the placeholder role name saved in your account template.$templateRole = newDocuSign\eSign\Model\TemplateRole();
$templateRole->setEmail("[SIGNER_EMAIL]");
$templateRole->setName("[SIGNER_NAME]");
$templateRole->setRoleName("[ROLE_NAME]"); // instantiate a new envelope object and configure settings$envelop_definition = newDocuSign\eSign\Model\EnvelopeDefinition();
$envelop_definition->setEmailSubject("[DocuSign PHP SDK] - Signature Request Sample");
$envelop_definition->setTemplateId("[TEMPLATE_ID]");
$envelop_definition->setTemplateRoles(array($templateRole));
// set envelope status to "sent" to immediately send the signature request$envelop_definition->setStatus("sent");
// optional envelope parameters$options = new \DocuSign\eSign\Api\EnvelopesApi\CreateEnvelopeOptions();
$options->setCdseMode(null);
$options->setMergeRolesOnDraft(null);
// create and send the envelope (aka signature request)$envelop_summary = $envelopeApi->createEnvelope($accountId, $envelop_definition, $options);
if(!empty($envelop_summary))
{
echo"$envelop_summary";
}
}
}
}
}
catch (DocuSign\eSign\ApiException$ex)
{
echo"Exception: " . $ex->getMessage() . "\n";
}
}
}
?>

See UnitTests.php for more examples.

Authentication

Service Integrations that use Legacy Header Authentication

(Legacy Header Authentication uses the X-DocuSign-Authentication header.)

  1. Use the Authentication: login method to retrieve the account number and the baseUrl for the account. The url for the login method is www.docusign.net for production and demo.docusign.net for the developer sandbox. The baseUrl field is part of the loginAccount object. See the docs and the loginAccount object
  2. The baseUrl for the selected account, in production, will start with na1, na2, na3, eu1, or something else. Use the baseUrl that is returned to create the basePath (see the next step.) Use the basePath for all of your subsequent API calls.
  3. As returned by login method, the baseUrl includes the API version and account id. Split the string to obtain the basePath, just the server name and api name. Eg, you will receive https://na1.docusign.net/restapi/v2/accounts/123123123. You want just https://na1.docusign.net/restapi
  4. Instantiate the SDK using the basePath. Eg ApiClient apiClient = new ApiClient(basePath);
  5. Set the authentication header as shown in the examples by using Configuration.Default.AddDefaultHeader

User Applications that use OAuth Authentication

  1. After obtaining a Bearer token, call the OAuth: Userinfo method. Obtain the selected account's base_uri (server name) field. The url for the Userinfo method is account-d.docusign.com for the demo/developer environment, and account.docusign.com for the production environment.
  2. Combine the base_uri with "/restapi" to create the basePath. The base_uri will start with na1, na2, na3, eu1, or something else. Use the basePath for your subsequent API calls.
  3. Instantiate the SDK using the basePath. Eg ApiClient apiClient = new ApiClient(basePath);
  4. Create the authentication_value by combining the token_type and access_token fields you receive from either an Authorization Code Grant or Implicit Grant OAuth flow.
  5. Set the authentication header by using Configuration.Default.AddDefaultHeader('Authorization', authentication_value)

Testing

Unit tests are available in the test folder.

Follow the steps below to run the test cases

  • Rename the "TestConfig.php-sample" to "TestConfig.php"

  • Populate all the required values like the login credentials, integrator key, host, etc in TestConfig.php

  • Run the following command from the test folder

     phpunit.phar UnitTests.php
    

Support

Feel free to log issues against this client through GitHub. We also have an active developer community on Stack Overflow, search the DocuSignAPI tag.

License

The DocuSign PHP Client is licensed under the following License.

Notes

This version of the client library does not implement all of the DocuSign REST API methods. The current client omits methods in the Accounts, Billing, Cloud Storage, Connect, Groups (Branding), and Templates (Bulk Recipients) categories. The client's methods support the core set of use cases that most integrations will encounter. For a complete list of omitted endpoints, see Omitted Endpoints.

About

The Official DocuSign PHP Client Library used to interact with the eSign REST API. Send, sign, and approve documents using this client.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Force GitHub README to respect dark mode (function() { var style = document.createElement('style'); style.textContent = ' .markdown-body { color-scheme: dark light; } .markdown-body pre { background: #161b22 !important; } .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; } .markdown-body table th, .markdown-body table td { border-color: #30363d !important; } .markdown-body img { background: #0d1117; } .markdown-body blockquote { border-left-color: #8b949e; } .markdown-body hr { border-color: #30363d; } '; document.head.appendChild(style); })(); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Latest commit

History

98 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

The Official DocuSign PHP Client

Build status

You can sign up for a free developer sandbox.

Requirements

PHP 5.4+ or higher [http://www.php.net/].

Installation

Composer

You can install the bindings via Composer. Run the following command:

composer require docusign/esign-client

To use the bindings, use Composer's autoload:

require_once('vendor/autoload.php');

Manual Install

If you do not wish to use Composer, you can download the latest release. Then, to use the bindings, include the init.php file.

require_once('/path/to/docusign-esign-client/autoload.php');

Dependencies

This client has the following external dependencies:

Usage

To login and send a signature request from a template:

<?phprequire_once('docusign-php-client/autoload.php');
class DocuSignSample
{
publicfunctionsignatureRequestFromTemplate()
{
$username = "[EMAIL]";
$password = "[PASSWORD]";
$integrator_key = "[INTEGRATOR_KEY]"; // change to production (www.docusign.net) before going live$host = "https://demo.docusign.net/restapi";
// create configuration object and configure custom auth header$config = newDocuSign\eSign\Configuration();
$config->setHost($host);
$config->addDefaultHeader("X-DocuSign-Authentication", "{\"Username\":\"" . $username . "\",\"Password\":\"" . $password . "\",\"IntegratorKey\":\"" . $integrator_key . "\"}");
// instantiate a new docusign api client$apiClient = newDocuSign\eSign\ApiClient($config);
$accountId = null;
try {
//*** STEP 1 - Login API: get first Account ID and baseURL$authenticationApi = newDocuSign\eSign\Api\AuthenticationApi($apiClient);
$options = new \DocuSign\eSign\Api\AuthenticationApi\LoginOptions();
$loginInformation = $authenticationApi->login($options);
if(isset($loginInformation) && count($loginInformation) > 0)
{
$loginAccount = $loginInformation->getLoginAccounts()[0];
$host = $loginAccount->getBaseUrl();
$host = explode("/v2",$host);
$host = $host[0];
// UPDATE configuration object$config->setHost($host);
// instantiate a NEW docusign api client (that has the correct baseUrl/host)$apiClient = newDocuSign\eSign\ApiClient($config);
if(isset($loginInformation))
{
$accountId = $loginAccount->getAccountId();
if(!empty($accountId))
{
//*** STEP 2 - Signature Request from a Template// create envelope call is available in the EnvelopesApi$envelopeApi = newDocuSign\eSign\Api\EnvelopesApi($apiClient);
// assign recipient to template role by setting name, email, and role name. Note that the// template role name must match the placeholder role name saved in your account template.$templateRole = newDocuSign\eSign\Model\TemplateRole();
$templateRole->setEmail("[SIGNER_EMAIL]");
$templateRole->setName("[SIGNER_NAME]");
$templateRole->setRoleName("[ROLE_NAME]"); // instantiate a new envelope object and configure settings$envelop_definition = newDocuSign\eSign\Model\EnvelopeDefinition();
$envelop_definition->setEmailSubject("[DocuSign PHP SDK] - Signature Request Sample");
$envelop_definition->setTemplateId("[TEMPLATE_ID]");
$envelop_definition->setTemplateRoles(array($templateRole));
// set envelope status to "sent" to immediately send the signature request$envelop_definition->setStatus("sent");
// optional envelope parameters$options = new \DocuSign\eSign\Api\EnvelopesApi\CreateEnvelopeOptions();
$options->setCdseMode(null);
$options->setMergeRolesOnDraft(null);
// create and send the envelope (aka signature request)$envelop_summary = $envelopeApi->createEnvelope($accountId, $envelop_definition, $options);
if(!empty($envelop_summary))
{
echo"$envelop_summary";
}
}
}
}
}
catch (DocuSign\eSign\ApiException$ex)
{
echo"Exception: " . $ex->getMessage() . "\n";
}
}
}
?>

See UnitTests.php for more examples.

Authentication

Service Integrations that use Legacy Header Authentication

(Legacy Header Authentication uses the X-DocuSign-Authentication header.)

  1. Use the Authentication: login method to retrieve the account number and the baseUrl for the account. The url for the login method is www.docusign.net for production and demo.docusign.net for the developer sandbox. The baseUrl field is part of the loginAccount object. See the docs and the loginAccount object
  2. The baseUrl for the selected account, in production, will start with na1, na2, na3, eu1, or something else. Use the baseUrl that is returned to create the basePath (see the next step.) Use the basePath for all of your subsequent API calls.
  3. As returned by login method, the baseUrl includes the API version and account id. Split the string to obtain the basePath, just the server name and api name. Eg, you will receive https://na1.docusign.net/restapi/v2/accounts/123123123. You want just https://na1.docusign.net/restapi
  4. Instantiate the SDK using the basePath. Eg ApiClient apiClient = new ApiClient(basePath);
  5. Set the authentication header as shown in the examples by using Configuration.Default.AddDefaultHeader

User Applications that use OAuth Authentication

  1. After obtaining a Bearer token, call the OAuth: Userinfo method. Obtain the selected account's base_uri (server name) field. The url for the Userinfo method is account-d.docusign.com for the demo/developer environment, and account.docusign.com for the production environment.
  2. Combine the base_uri with "/restapi" to create the basePath. The base_uri will start with na1, na2, na3, eu1, or something else. Use the basePath for your subsequent API calls.
  3. Instantiate the SDK using the basePath. Eg ApiClient apiClient = new ApiClient(basePath);
  4. Create the authentication_value by combining the token_type and access_token fields you receive from either an Authorization Code Grant or Implicit Grant OAuth flow.
  5. Set the authentication header by using Configuration.Default.AddDefaultHeader('Authorization', authentication_value)

Testing

Unit tests are available in the test folder.

Follow the steps below to run the test cases

  • Rename the "TestConfig.php-sample" to "TestConfig.php"

  • Populate all the required values like the login credentials, integrator key, host, etc in TestConfig.php

  • Run the following command from the test folder

     phpunit.phar UnitTests.php
    

Support

Feel free to log issues against this client through GitHub. We also have an active developer community on Stack Overflow, search the DocuSignAPI tag.

License

The DocuSign PHP Client is licensed under the following License.

Notes

This version of the client library does not implement all of the DocuSign REST API methods. The current client omits methods in the Accounts, Billing, Cloud Storage, Connect, Groups (Branding), and Templates (Bulk Recipients) categories. The client's methods support the core set of use cases that most integrations will encounter. For a complete list of omitted endpoints, see Omitted Endpoints.

About

The Official DocuSign PHP Client Library used to interact with the eSign REST API. Send, sign, and approve documents using this client.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Highlight search terms from Google/DuckDuckGo/Bing referrer (function() { var ref = document.referrer; var terms = []; if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) { var url = new URL(ref); var q = url.searchParams.get('q') || url.searchParams.get('p'); if (q) { terms = q.split(/\s+/).filter(function(t) { return t.length > 2; }); } } if (terms.length === 0) return; var style = document.createElement('style'); style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }'; document.head.appendChild(style); function highlight(node) { if (node.nodeType === 3) { // text node var text = node.textContent; var found = false; terms.forEach(function(term) { var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\]\\]/g, '\\') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Latest commit

History

98 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

The Official DocuSign PHP Client

Build status

You can sign up for a free developer sandbox.

Requirements

PHP 5.4+ or higher [http://www.php.net/].

Installation

Composer

You can install the bindings via Composer. Run the following command:

composer require docusign/esign-client

To use the bindings, use Composer's autoload:

require_once('vendor/autoload.php');

Manual Install

If you do not wish to use Composer, you can download the latest release. Then, to use the bindings, include the init.php file.

require_once('/path/to/docusign-esign-client/autoload.php');

Dependencies

This client has the following external dependencies:

Usage

To login and send a signature request from a template:

<?phprequire_once('docusign-php-client/autoload.php');
class DocuSignSample
{
publicfunctionsignatureRequestFromTemplate()
{
$username = "[EMAIL]";
$password = "[PASSWORD]";
$integrator_key = "[INTEGRATOR_KEY]"; // change to production (www.docusign.net) before going live$host = "https://demo.docusign.net/restapi";
// create configuration object and configure custom auth header$config = newDocuSign\eSign\Configuration();
$config->setHost($host);
$config->addDefaultHeader("X-DocuSign-Authentication", "{\"Username\":\"" . $username . "\",\"Password\":\"" . $password . "\",\"IntegratorKey\":\"" . $integrator_key . "\"}");
// instantiate a new docusign api client$apiClient = newDocuSign\eSign\ApiClient($config);
$accountId = null;
try {
//*** STEP 1 - Login API: get first Account ID and baseURL$authenticationApi = newDocuSign\eSign\Api\AuthenticationApi($apiClient);
$options = new \DocuSign\eSign\Api\AuthenticationApi\LoginOptions();
$loginInformation = $authenticationApi->login($options);
if(isset($loginInformation) && count($loginInformation) > 0)
{
$loginAccount = $loginInformation->getLoginAccounts()[0];
$host = $loginAccount->getBaseUrl();
$host = explode("/v2",$host);
$host = $host[0];
// UPDATE configuration object$config->setHost($host);
// instantiate a NEW docusign api client (that has the correct baseUrl/host)$apiClient = newDocuSign\eSign\ApiClient($config);
if(isset($loginInformation))
{
$accountId = $loginAccount->getAccountId();
if(!empty($accountId))
{
//*** STEP 2 - Signature Request from a Template// create envelope call is available in the EnvelopesApi$envelopeApi = newDocuSign\eSign\Api\EnvelopesApi($apiClient);
// assign recipient to template role by setting name, email, and role name. Note that the// template role name must match the placeholder role name saved in your account template.$templateRole = newDocuSign\eSign\Model\TemplateRole();
$templateRole->setEmail("[SIGNER_EMAIL]");
$templateRole->setName("[SIGNER_NAME]");
$templateRole->setRoleName("[ROLE_NAME]"); // instantiate a new envelope object and configure settings$envelop_definition = newDocuSign\eSign\Model\EnvelopeDefinition();
$envelop_definition->setEmailSubject("[DocuSign PHP SDK] - Signature Request Sample");
$envelop_definition->setTemplateId("[TEMPLATE_ID]");
$envelop_definition->setTemplateRoles(array($templateRole));
// set envelope status to "sent" to immediately send the signature request$envelop_definition->setStatus("sent");
// optional envelope parameters$options = new \DocuSign\eSign\Api\EnvelopesApi\CreateEnvelopeOptions();
$options->setCdseMode(null);
$options->setMergeRolesOnDraft(null);
// create and send the envelope (aka signature request)$envelop_summary = $envelopeApi->createEnvelope($accountId, $envelop_definition, $options);
if(!empty($envelop_summary))
{
echo"$envelop_summary";
}
}
}
}
}
catch (DocuSign\eSign\ApiException$ex)
{
echo"Exception: " . $ex->getMessage() . "\n";
}
}
}
?>

See UnitTests.php for more examples.

Authentication

Service Integrations that use Legacy Header Authentication

(Legacy Header Authentication uses the X-DocuSign-Authentication header.)

  1. Use the Authentication: login method to retrieve the account number and the baseUrl for the account. The url for the login method is www.docusign.net for production and demo.docusign.net for the developer sandbox. The baseUrl field is part of the loginAccount object. See the docs and the loginAccount object
  2. The baseUrl for the selected account, in production, will start with na1, na2, na3, eu1, or something else. Use the baseUrl that is returned to create the basePath (see the next step.) Use the basePath for all of your subsequent API calls.
  3. As returned by login method, the baseUrl includes the API version and account id. Split the string to obtain the basePath, just the server name and api name. Eg, you will receive https://na1.docusign.net/restapi/v2/accounts/123123123. You want just https://na1.docusign.net/restapi
  4. Instantiate the SDK using the basePath. Eg ApiClient apiClient = new ApiClient(basePath);
  5. Set the authentication header as shown in the examples by using Configuration.Default.AddDefaultHeader

User Applications that use OAuth Authentication

  1. After obtaining a Bearer token, call the OAuth: Userinfo method. Obtain the selected account's base_uri (server name) field. The url for the Userinfo method is account-d.docusign.com for the demo/developer environment, and account.docusign.com for the production environment.
  2. Combine the base_uri with "/restapi" to create the basePath. The base_uri will start with na1, na2, na3, eu1, or something else. Use the basePath for your subsequent API calls.
  3. Instantiate the SDK using the basePath. Eg ApiClient apiClient = new ApiClient(basePath);
  4. Create the authentication_value by combining the token_type and access_token fields you receive from either an Authorization Code Grant or Implicit Grant OAuth flow.
  5. Set the authentication header by using Configuration.Default.AddDefaultHeader('Authorization', authentication_value)

Testing

Unit tests are available in the test folder.

Follow the steps below to run the test cases

  • Rename the "TestConfig.php-sample" to "TestConfig.php"

  • Populate all the required values like the login credentials, integrator key, host, etc in TestConfig.php

  • Run the following command from the test folder

     phpunit.phar UnitTests.php
    

Support

Feel free to log issues against this client through GitHub. We also have an active developer community on Stack Overflow, search the DocuSignAPI tag.

License

The DocuSign PHP Client is licensed under the following License.

Notes

This version of the client library does not implement all of the DocuSign REST API methods. The current client omits methods in the Accounts, Billing, Cloud Storage, Connect, Groups (Branding), and Templates (Bulk Recipients) categories. The client's methods support the core set of use cases that most integrations will encounter. For a complete list of omitted endpoints, see Omitted Endpoints.

About

The Official DocuSign PHP Client Library used to interact with the eSign REST API. Send, sign, and approve documents using this client.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

Latest commit

History

98 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

The Official DocuSign PHP Client

Build status

You can sign up for a free developer sandbox.

Requirements

PHP 5.4+ or higher [http://www.php.net/].

Installation

Composer

You can install the bindings via Composer. Run the following command:

composer require docusign/esign-client

To use the bindings, use Composer's autoload:

require_once('vendor/autoload.php');

Manual Install

If you do not wish to use Composer, you can download the latest release. Then, to use the bindings, include the init.php file.

require_once('/path/to/docusign-esign-client/autoload.php');

Dependencies

This client has the following external dependencies:

Usage

To login and send a signature request from a template:

<?phprequire_once('docusign-php-client/autoload.php');
class DocuSignSample
{
publicfunctionsignatureRequestFromTemplate()
{
$username = "[EMAIL]";
$password = "[PASSWORD]";
$integrator_key = "[INTEGRATOR_KEY]"; // change to production (www.docusign.net) before going live$host = "https://demo.docusign.net/restapi";
// create configuration object and configure custom auth header$config = newDocuSign\eSign\Configuration();
$config->setHost($host);
$config->addDefaultHeader("X-DocuSign-Authentication", "{\"Username\":\"" . $username . "\",\"Password\":\"" . $password . "\",\"IntegratorKey\":\"" . $integrator_key . "\"}");
// instantiate a new docusign api client$apiClient = newDocuSign\eSign\ApiClient($config);
$accountId = null;
try {
//*** STEP 1 - Login API: get first Account ID and baseURL$authenticationApi = newDocuSign\eSign\Api\AuthenticationApi($apiClient);
$options = new \DocuSign\eSign\Api\AuthenticationApi\LoginOptions();
$loginInformation = $authenticationApi->login($options);
if(isset($loginInformation) && count($loginInformation) > 0)
{
$loginAccount = $loginInformation->getLoginAccounts()[0];
$host = $loginAccount->getBaseUrl();
$host = explode("/v2",$host);
$host = $host[0];
// UPDATE configuration object$config->setHost($host);
// instantiate a NEW docusign api client (that has the correct baseUrl/host)$apiClient = newDocuSign\eSign\ApiClient($config);
if(isset($loginInformation))
{
$accountId = $loginAccount->getAccountId();
if(!empty($accountId))
{
//*** STEP 2 - Signature Request from a Template// create envelope call is available in the EnvelopesApi$envelopeApi = newDocuSign\eSign\Api\EnvelopesApi($apiClient);
// assign recipient to template role by setting name, email, and role name. Note that the// template role name must match the placeholder role name saved in your account template.$templateRole = newDocuSign\eSign\Model\TemplateRole();
$templateRole->setEmail("[SIGNER_EMAIL]");
$templateRole->setName("[SIGNER_NAME]");
$templateRole->setRoleName("[ROLE_NAME]"); // instantiate a new envelope object and configure settings$envelop_definition = newDocuSign\eSign\Model\EnvelopeDefinition();
$envelop_definition->setEmailSubject("[DocuSign PHP SDK] - Signature Request Sample");
$envelop_definition->setTemplateId("[TEMPLATE_ID]");
$envelop_definition->setTemplateRoles(array($templateRole));
// set envelope status to "sent" to immediately send the signature request$envelop_definition->setStatus("sent");
// optional envelope parameters$options = new \DocuSign\eSign\Api\EnvelopesApi\CreateEnvelopeOptions();
$options->setCdseMode(null);
$options->setMergeRolesOnDraft(null);
// create and send the envelope (aka signature request)$envelop_summary = $envelopeApi->createEnvelope($accountId, $envelop_definition, $options);
if(!empty($envelop_summary))
{
echo"$envelop_summary";
}
}
}
}
}
catch (DocuSign\eSign\ApiException$ex)
{
echo"Exception: " . $ex->getMessage() . "\n";
}
}
}
?>

See UnitTests.php for more examples.

Authentication

Service Integrations that use Legacy Header Authentication

(Legacy Header Authentication uses the X-DocuSign-Authentication header.)

  1. Use the Authentication: login method to retrieve the account number and the baseUrl for the account. The url for the login method is www.docusign.net for production and demo.docusign.net for the developer sandbox. The baseUrl field is part of the loginAccount object. See the docs and the loginAccount object
  2. The baseUrl for the selected account, in production, will start with na1, na2, na3, eu1, or something else. Use the baseUrl that is returned to create the basePath (see the next step.) Use the basePath for all of your subsequent API calls.
  3. As returned by login method, the baseUrl includes the API version and account id. Split the string to obtain the basePath, just the server name and api name. Eg, you will receive https://na1.docusign.net/restapi/v2/accounts/123123123. You want just https://na1.docusign.net/restapi
  4. Instantiate the SDK using the basePath. Eg ApiClient apiClient = new ApiClient(basePath);
  5. Set the authentication header as shown in the examples by using Configuration.Default.AddDefaultHeader

User Applications that use OAuth Authentication

  1. After obtaining a Bearer token, call the OAuth: Userinfo method. Obtain the selected account's base_uri (server name) field. The url for the Userinfo method is account-d.docusign.com for the demo/developer environment, and account.docusign.com for the production environment.
  2. Combine the base_uri with "/restapi" to create the basePath. The base_uri will start with na1, na2, na3, eu1, or something else. Use the basePath for your subsequent API calls.
  3. Instantiate the SDK using the basePath. Eg ApiClient apiClient = new ApiClient(basePath);
  4. Create the authentication_value by combining the token_type and access_token fields you receive from either an Authorization Code Grant or Implicit Grant OAuth flow.
  5. Set the authentication header by using Configuration.Default.AddDefaultHeader('Authorization', authentication_value)

Testing

Unit tests are available in the test folder.

Follow the steps below to run the test cases

  • Rename the "TestConfig.php-sample" to "TestConfig.php"

  • Populate all the required values like the login credentials, integrator key, host, etc in TestConfig.php

  • Run the following command from the test folder

     phpunit.phar UnitTests.php
    

Support

Feel free to log issues against this client through GitHub. We also have an active developer community on Stack Overflow, search the DocuSignAPI tag.

License

The DocuSign PHP Client is licensed under the following License.

Notes

This version of the client library does not implement all of the DocuSign REST API methods. The current client omits methods in the Accounts, Billing, Cloud Storage, Connect, Groups (Branding), and Templates (Bulk Recipients) categories. The client's methods support the core set of use cases that most integrations will encounter. For a complete list of omitted endpoints, see Omitted Endpoints.

About

The Official DocuSign PHP Client Library used to interact with the eSign REST API. Send, sign, and approve documents using this client.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Latest commit

History

98 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

The Official DocuSign PHP Client

Build status

You can sign up for a free developer sandbox.

Requirements

PHP 5.4+ or higher [http://www.php.net/].

Installation

Composer

You can install the bindings via Composer. Run the following command:

composer require docusign/esign-client

To use the bindings, use Composer's autoload:

require_once('vendor/autoload.php');

Manual Install

If you do not wish to use Composer, you can download the latest release. Then, to use the bindings, include the init.php file.

require_once('/path/to/docusign-esign-client/autoload.php');

Dependencies

This client has the following external dependencies:

Usage

To login and send a signature request from a template:

<?phprequire_once('docusign-php-client/autoload.php');
class DocuSignSample
{
publicfunctionsignatureRequestFromTemplate()
{
$username = "[EMAIL]";
$password = "[PASSWORD]";
$integrator_key = "[INTEGRATOR_KEY]"; // change to production (www.docusign.net) before going live$host = "https://demo.docusign.net/restapi";
// create configuration object and configure custom auth header$config = newDocuSign\eSign\Configuration();
$config->setHost($host);
$config->addDefaultHeader("X-DocuSign-Authentication", "{\"Username\":\"" . $username . "\",\"Password\":\"" . $password . "\",\"IntegratorKey\":\"" . $integrator_key . "\"}");
// instantiate a new docusign api client$apiClient = newDocuSign\eSign\ApiClient($config);
$accountId = null;
try {
//*** STEP 1 - Login API: get first Account ID and baseURL$authenticationApi = newDocuSign\eSign\Api\AuthenticationApi($apiClient);
$options = new \DocuSign\eSign\Api\AuthenticationApi\LoginOptions();
$loginInformation = $authenticationApi->login($options);
if(isset($loginInformation) && count($loginInformation) > 0)
{
$loginAccount = $loginInformation->getLoginAccounts()[0];
$host = $loginAccount->getBaseUrl();
$host = explode("/v2",$host);
$host = $host[0];
// UPDATE configuration object$config->setHost($host);
// instantiate a NEW docusign api client (that has the correct baseUrl/host)$apiClient = newDocuSign\eSign\ApiClient($config);
if(isset($loginInformation))
{
$accountId = $loginAccount->getAccountId();
if(!empty($accountId))
{
//*** STEP 2 - Signature Request from a Template// create envelope call is available in the EnvelopesApi$envelopeApi = newDocuSign\eSign\Api\EnvelopesApi($apiClient);
// assign recipient to template role by setting name, email, and role name. Note that the// template role name must match the placeholder role name saved in your account template.$templateRole = newDocuSign\eSign\Model\TemplateRole();
$templateRole->setEmail("[SIGNER_EMAIL]");
$templateRole->setName("[SIGNER_NAME]");
$templateRole->setRoleName("[ROLE_NAME]"); // instantiate a new envelope object and configure settings$envelop_definition = newDocuSign\eSign\Model\EnvelopeDefinition();
$envelop_definition->setEmailSubject("[DocuSign PHP SDK] - Signature Request Sample");
$envelop_definition->setTemplateId("[TEMPLATE_ID]");
$envelop_definition->setTemplateRoles(array($templateRole));
// set envelope status to "sent" to immediately send the signature request$envelop_definition->setStatus("sent");
// optional envelope parameters$options = new \DocuSign\eSign\Api\EnvelopesApi\CreateEnvelopeOptions();
$options->setCdseMode(null);
$options->setMergeRolesOnDraft(null);
// create and send the envelope (aka signature request)$envelop_summary = $envelopeApi->createEnvelope($accountId, $envelop_definition, $options);
if(!empty($envelop_summary))
{
echo"$envelop_summary";
}
}
}
}
}
catch (DocuSign\eSign\ApiException$ex)
{
echo"Exception: " . $ex->getMessage() . "\n";
}
}
}
?>

See UnitTests.php for more examples.

Authentication

Service Integrations that use Legacy Header Authentication

(Legacy Header Authentication uses the X-DocuSign-Authentication header.)

  1. Use the Authentication: login method to retrieve the account number and the baseUrl for the account. The url for the login method is www.docusign.net for production and demo.docusign.net for the developer sandbox. The baseUrl field is part of the loginAccount object. See the docs and the loginAccount object
  2. The baseUrl for the selected account, in production, will start with na1, na2, na3, eu1, or something else. Use the baseUrl that is returned to create the basePath (see the next step.) Use the basePath for all of your subsequent API calls.
  3. As returned by login method, the baseUrl includes the API version and account id. Split the string to obtain the basePath, just the server name and api name. Eg, you will receive https://na1.docusign.net/restapi/v2/accounts/123123123. You want just https://na1.docusign.net/restapi
  4. Instantiate the SDK using the basePath. Eg ApiClient apiClient = new ApiClient(basePath);
  5. Set the authentication header as shown in the examples by using Configuration.Default.AddDefaultHeader

User Applications that use OAuth Authentication

  1. After obtaining a Bearer token, call the OAuth: Userinfo method. Obtain the selected account's base_uri (server name) field. The url for the Userinfo method is account-d.docusign.com for the demo/developer environment, and account.docusign.com for the production environment.
  2. Combine the base_uri with "/restapi" to create the basePath. The base_uri will start with na1, na2, na3, eu1, or something else. Use the basePath for your subsequent API calls.
  3. Instantiate the SDK using the basePath. Eg ApiClient apiClient = new ApiClient(basePath);
  4. Create the authentication_value by combining the token_type and access_token fields you receive from either an Authorization Code Grant or Implicit Grant OAuth flow.
  5. Set the authentication header by using Configuration.Default.AddDefaultHeader('Authorization', authentication_value)

Testing

Unit tests are available in the test folder.

Follow the steps below to run the test cases

  • Rename the "TestConfig.php-sample" to "TestConfig.php"

  • Populate all the required values like the login credentials, integrator key, host, etc in TestConfig.php

  • Run the following command from the test folder

     phpunit.phar UnitTests.php
    

Support

Feel free to log issues against this client through GitHub. We also have an active developer community on Stack Overflow, search the DocuSignAPI tag.

License

The DocuSign PHP Client is licensed under the following License.

Notes

This version of the client library does not implement all of the DocuSign REST API methods. The current client omits methods in the Accounts, Billing, Cloud Storage, Connect, Groups (Branding), and Templates (Bulk Recipients) categories. The client's methods support the core set of use cases that most integrations will encounter. For a complete list of omitted endpoints, see Omitted Endpoints.

About

The Official DocuSign PHP Client Library used to interact with the eSign REST API. Send, sign, and approve documents using this client.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Latest commit

History

98 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

The Official DocuSign PHP Client

Build status

You can sign up for a free developer sandbox.

Requirements

PHP 5.4+ or higher [http://www.php.net/].

Installation

Composer

You can install the bindings via Composer. Run the following command:

composer require docusign/esign-client

To use the bindings, use Composer's autoload:

require_once('vendor/autoload.php');

Manual Install

If you do not wish to use Composer, you can download the latest release. Then, to use the bindings, include the init.php file.

require_once('/path/to/docusign-esign-client/autoload.php');

Dependencies

This client has the following external dependencies:

Usage

To login and send a signature request from a template:

<?phprequire_once('docusign-php-client/autoload.php');
class DocuSignSample
{
publicfunctionsignatureRequestFromTemplate()
{
$username = "[EMAIL]";
$password = "[PASSWORD]";
$integrator_key = "[INTEGRATOR_KEY]"; // change to production (www.docusign.net) before going live$host = "https://demo.docusign.net/restapi";
// create configuration object and configure custom auth header$config = newDocuSign\eSign\Configuration();
$config->setHost($host);
$config->addDefaultHeader("X-DocuSign-Authentication", "{\"Username\":\"" . $username . "\",\"Password\":\"" . $password . "\",\"IntegratorKey\":\"" . $integrator_key . "\"}");
// instantiate a new docusign api client$apiClient = newDocuSign\eSign\ApiClient($config);
$accountId = null;
try {
//*** STEP 1 - Login API: get first Account ID and baseURL$authenticationApi = newDocuSign\eSign\Api\AuthenticationApi($apiClient);
$options = new \DocuSign\eSign\Api\AuthenticationApi\LoginOptions();
$loginInformation = $authenticationApi->login($options);
if(isset($loginInformation) && count($loginInformation) > 0)
{
$loginAccount = $loginInformation->getLoginAccounts()[0];
$host = $loginAccount->getBaseUrl();
$host = explode("/v2",$host);
$host = $host[0];
// UPDATE configuration object$config->setHost($host);
// instantiate a NEW docusign api client (that has the correct baseUrl/host)$apiClient = newDocuSign\eSign\ApiClient($config);
if(isset($loginInformation))
{
$accountId = $loginAccount->getAccountId();
if(!empty($accountId))
{
//*** STEP 2 - Signature Request from a Template// create envelope call is available in the EnvelopesApi$envelopeApi = newDocuSign\eSign\Api\EnvelopesApi($apiClient);
// assign recipient to template role by setting name, email, and role name. Note that the// template role name must match the placeholder role name saved in your account template.$templateRole = newDocuSign\eSign\Model\TemplateRole();
$templateRole->setEmail("[SIGNER_EMAIL]");
$templateRole->setName("[SIGNER_NAME]");
$templateRole->setRoleName("[ROLE_NAME]"); // instantiate a new envelope object and configure settings$envelop_definition = newDocuSign\eSign\Model\EnvelopeDefinition();
$envelop_definition->setEmailSubject("[DocuSign PHP SDK] - Signature Request Sample");
$envelop_definition->setTemplateId("[TEMPLATE_ID]");
$envelop_definition->setTemplateRoles(array($templateRole));
// set envelope status to "sent" to immediately send the signature request$envelop_definition->setStatus("sent");
// optional envelope parameters$options = new \DocuSign\eSign\Api\EnvelopesApi\CreateEnvelopeOptions();
$options->setCdseMode(null);
$options->setMergeRolesOnDraft(null);
// create and send the envelope (aka signature request)$envelop_summary = $envelopeApi->createEnvelope($accountId, $envelop_definition, $options);
if(!empty($envelop_summary))
{
echo"$envelop_summary";
}
}
}
}
}
catch (DocuSign\eSign\ApiException$ex)
{
echo"Exception: " . $ex->getMessage() . "\n";
}
}
}
?>

See UnitTests.php for more examples.

Authentication

Service Integrations that use Legacy Header Authentication

(Legacy Header Authentication uses the X-DocuSign-Authentication header.)

  1. Use the Authentication: login method to retrieve the account number and the baseUrl for the account. The url for the login method is www.docusign.net for production and demo.docusign.net for the developer sandbox. The baseUrl field is part of the loginAccount object. See the docs and the loginAccount object
  2. The baseUrl for the selected account, in production, will start with na1, na2, na3, eu1, or something else. Use the baseUrl that is returned to create the basePath (see the next step.) Use the basePath for all of your subsequent API calls.
  3. As returned by login method, the baseUrl includes the API version and account id. Split the string to obtain the basePath, just the server name and api name. Eg, you will receive https://na1.docusign.net/restapi/v2/accounts/123123123. You want just https://na1.docusign.net/restapi
  4. Instantiate the SDK using the basePath. Eg ApiClient apiClient = new ApiClient(basePath);
  5. Set the authentication header as shown in the examples by using Configuration.Default.AddDefaultHeader

User Applications that use OAuth Authentication

  1. After obtaining a Bearer token, call the OAuth: Userinfo method. Obtain the selected account's base_uri (server name) field. The url for the Userinfo method is account-d.docusign.com for the demo/developer environment, and account.docusign.com for the production environment.
  2. Combine the base_uri with "/restapi" to create the basePath. The base_uri will start with na1, na2, na3, eu1, or something else. Use the basePath for your subsequent API calls.
  3. Instantiate the SDK using the basePath. Eg ApiClient apiClient = new ApiClient(basePath);
  4. Create the authentication_value by combining the token_type and access_token fields you receive from either an Authorization Code Grant or Implicit Grant OAuth flow.
  5. Set the authentication header by using Configuration.Default.AddDefaultHeader('Authorization', authentication_value)

Testing

Unit tests are available in the test folder.

Follow the steps below to run the test cases

  • Rename the "TestConfig.php-sample" to "TestConfig.php"

  • Populate all the required values like the login credentials, integrator key, host, etc in TestConfig.php

  • Run the following command from the test folder

     phpunit.phar UnitTests.php
    

Support

Feel free to log issues against this client through GitHub. We also have an active developer community on Stack Overflow, search the DocuSignAPI tag.

License

The DocuSign PHP Client is licensed under the following License.

Notes

This version of the client library does not implement all of the DocuSign REST API methods. The current client omits methods in the Accounts, Billing, Cloud Storage, Connect, Groups (Branding), and Templates (Bulk Recipients) categories. The client's methods support the core set of use cases that most integrations will encounter. For a complete list of omitted endpoints, see Omitted Endpoints.

About

The Official DocuSign PHP Client Library used to interact with the eSign REST API. Send, sign, and approve documents using this client.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Universal Dark Mode - works on any site (function() { var enabled = true; function applyDarkMode() { if (!enabled) return; // Create style element if it doesn't exist var style = document.getElementById('universal-dark-mode-style'); if (!style) { style = document.createElement('style'); style.id = 'universal-dark-mode-style'; document.head.appendChild(style); } // Dark mode CSS - inverts colors but preserves images/video style.textContent = ' /* Invert everything except media */ html { filter: invert(1) hue-rotate(180deg) !important; background: #1a1a2e !important; } /* Restore images, videos, iframes, canvas */ img, video, iframe, canvas, svg, picture, [style*="background-image"] { filter: invert(1) hue-rotate(180deg) !important; } /* Preserve specific elements that should not be inverted */ .no-dark-mode, .no-dark-mode *, [data-theme="light"], [data-theme="light"], .ace_editor, .ace_editor *, .CodeMirror, .CodeMirror *, .monaco-editor, .monaco-editor *, .markdown-body pre, .markdown-body pre *, .highlight, .highlight *, pre code, pre code * { filter: none !important; } /* Fix common UI elements */ .modal, .popup, .dropdown-menu, .tooltip, .popover { filter: invert(1) hue-rotate(180deg) !important; background: #2d2d44 !important; border-color: #444 !important; } /* Scrollbars */ ::-webkit-scrollbar { background: #1a1a2e !important; } ::-webkit-scrollbar-thumb { background: #444 !important; } ::-webkit-scrollbar-thumb:hover { background: #555 !important; } /* Selection */ ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; } ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; } '; } function removeDarkMode() { var style = document.getElementById('universal-dark-mode-style'); if (style) style.remove(); } // Toggle with Alt+Shift+D document.addEventListener('keydown', function(e) { if (e.altKey && e.shiftKey && e.key === 'D') { e.preventDefault(); enabled = !enabled; if (enabled) { applyDarkMode(); console.log('[Universal Dark Mode] Enabled'); } else { removeDarkMode(); console.log('[Universal Dark Mode] Disabled'); } } }); // Apply on load applyDarkMode(); // Re-apply on dynamic content var observer = new MutationObserver(function(mutations) { if (enabled && !document.getElementById('universal-dark-mode-style')) { applyDarkMode(); } }); observer.observe(document.head, { childList: true }); console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle'); })(); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

Latest commit

History

98 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

The Official DocuSign PHP Client

Build status

You can sign up for a free developer sandbox.

Requirements

PHP 5.4+ or higher [http://www.php.net/].

Installation

Composer

You can install the bindings via Composer. Run the following command:

composer require docusign/esign-client

To use the bindings, use Composer's autoload:

require_once('vendor/autoload.php');

Manual Install

If you do not wish to use Composer, you can download the latest release. Then, to use the bindings, include the init.php file.

require_once('/path/to/docusign-esign-client/autoload.php');

Dependencies

This client has the following external dependencies:

Usage

To login and send a signature request from a template:

<?phprequire_once('docusign-php-client/autoload.php');
class DocuSignSample
{
publicfunctionsignatureRequestFromTemplate()
{
$username = "[EMAIL]";
$password = "[PASSWORD]";
$integrator_key = "[INTEGRATOR_KEY]"; // change to production (www.docusign.net) before going live$host = "https://demo.docusign.net/restapi";
// create configuration object and configure custom auth header$config = newDocuSign\eSign\Configuration();
$config->setHost($host);
$config->addDefaultHeader("X-DocuSign-Authentication", "{\"Username\":\"" . $username . "\",\"Password\":\"" . $password . "\",\"IntegratorKey\":\"" . $integrator_key . "\"}");
// instantiate a new docusign api client$apiClient = newDocuSign\eSign\ApiClient($config);
$accountId = null;
try {
//*** STEP 1 - Login API: get first Account ID and baseURL$authenticationApi = newDocuSign\eSign\Api\AuthenticationApi($apiClient);
$options = new \DocuSign\eSign\Api\AuthenticationApi\LoginOptions();
$loginInformation = $authenticationApi->login($options);
if(isset($loginInformation) && count($loginInformation) > 0)
{
$loginAccount = $loginInformation->getLoginAccounts()[0];
$host = $loginAccount->getBaseUrl();
$host = explode("/v2",$host);
$host = $host[0];
// UPDATE configuration object$config->setHost($host);
// instantiate a NEW docusign api client (that has the correct baseUrl/host)$apiClient = newDocuSign\eSign\ApiClient($config);
if(isset($loginInformation))
{
$accountId = $loginAccount->getAccountId();
if(!empty($accountId))
{
//*** STEP 2 - Signature Request from a Template// create envelope call is available in the EnvelopesApi$envelopeApi = newDocuSign\eSign\Api\EnvelopesApi($apiClient);
// assign recipient to template role by setting name, email, and role name. Note that the// template role name must match the placeholder role name saved in your account template.$templateRole = newDocuSign\eSign\Model\TemplateRole();
$templateRole->setEmail("[SIGNER_EMAIL]");
$templateRole->setName("[SIGNER_NAME]");
$templateRole->setRoleName("[ROLE_NAME]"); // instantiate a new envelope object and configure settings$envelop_definition = newDocuSign\eSign\Model\EnvelopeDefinition();
$envelop_definition->setEmailSubject("[DocuSign PHP SDK] - Signature Request Sample");
$envelop_definition->setTemplateId("[TEMPLATE_ID]");
$envelop_definition->setTemplateRoles(array($templateRole));
// set envelope status to "sent" to immediately send the signature request$envelop_definition->setStatus("sent");
// optional envelope parameters$options = new \DocuSign\eSign\Api\EnvelopesApi\CreateEnvelopeOptions();
$options->setCdseMode(null);
$options->setMergeRolesOnDraft(null);
// create and send the envelope (aka signature request)$envelop_summary = $envelopeApi->createEnvelope($accountId, $envelop_definition, $options);
if(!empty($envelop_summary))
{
echo"$envelop_summary";
}
}
}
}
}
catch (DocuSign\eSign\ApiException$ex)
{
echo"Exception: " . $ex->getMessage() . "\n";
}
}
}
?>

See UnitTests.php for more examples.

Authentication

Service Integrations that use Legacy Header Authentication

(Legacy Header Authentication uses the X-DocuSign-Authentication header.)

  1. Use the Authentication: login method to retrieve the account number and the baseUrl for the account. The url for the login method is www.docusign.net for production and demo.docusign.net for the developer sandbox. The baseUrl field is part of the loginAccount object. See the docs and the loginAccount object
  2. The baseUrl for the selected account, in production, will start with na1, na2, na3, eu1, or something else. Use the baseUrl that is returned to create the basePath (see the next step.) Use the basePath for all of your subsequent API calls.
  3. As returned by login method, the baseUrl includes the API version and account id. Split the string to obtain the basePath, just the server name and api name. Eg, you will receive https://na1.docusign.net/restapi/v2/accounts/123123123. You want just https://na1.docusign.net/restapi
  4. Instantiate the SDK using the basePath. Eg ApiClient apiClient = new ApiClient(basePath);
  5. Set the authentication header as shown in the examples by using Configuration.Default.AddDefaultHeader

User Applications that use OAuth Authentication

  1. After obtaining a Bearer token, call the OAuth: Userinfo method. Obtain the selected account's base_uri (server name) field. The url for the Userinfo method is account-d.docusign.com for the demo/developer environment, and account.docusign.com for the production environment.
  2. Combine the base_uri with "/restapi" to create the basePath. The base_uri will start with na1, na2, na3, eu1, or something else. Use the basePath for your subsequent API calls.
  3. Instantiate the SDK using the basePath. Eg ApiClient apiClient = new ApiClient(basePath);
  4. Create the authentication_value by combining the token_type and access_token fields you receive from either an Authorization Code Grant or Implicit Grant OAuth flow.
  5. Set the authentication header by using Configuration.Default.AddDefaultHeader('Authorization', authentication_value)

Testing

Unit tests are available in the test folder.

Follow the steps below to run the test cases

  • Rename the "TestConfig.php-sample" to "TestConfig.php"

  • Populate all the required values like the login credentials, integrator key, host, etc in TestConfig.php

  • Run the following command from the test folder

     phpunit.phar UnitTests.php
    

Support

Feel free to log issues against this client through GitHub. We also have an active developer community on Stack Overflow, search the DocuSignAPI tag.

License

The DocuSign PHP Client is licensed under the following License.

Notes

This version of the client library does not implement all of the DocuSign REST API methods. The current client omits methods in the Accounts, Billing, Cloud Storage, Connect, Groups (Branding), and Templates (Bulk Recipients) categories. The client's methods support the core set of use cases that most integrations will encounter. For a complete list of omitted endpoints, see Omitted Endpoints.

About

The Official DocuSign PHP Client Library used to interact with the eSign REST API. Send, sign, and approve documents using this client.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages