### Install HelloSign PHP SDK with Composer Source: https://github.com/hellosign/hellosign-php-sdk/blob/v3/README.md Instructions for installing the HelloSign PHP SDK using Composer, including creating a composer.json file and running the install command. ```shell curl -sS https://getcomposer.org/installer | php { "require": { "hellosign/hellosign-php-sdk": "^3.0" } } php composer.phar install require_once 'vendor/autoload.php'; ``` -------------------------------- ### Test Authentication and Retrieve Account Source: https://github.com/hellosign/hellosign-php-sdk/blob/v3/README.md A simple example to test the HelloSign client authentication by retrieving the account information. ```php $account = $client->getAccount(); ``` -------------------------------- ### Retrieve and Iterate Through User Templates Source: https://github.com/hellosign/hellosign-php-sdk/blob/v3/README.md Code example for retrieving a paginated list of user templates from the HelloSign API and iterating through them to display their titles. ```php $templates = $client->getTemplates($page_number); foreach ($templates as $template) { echo $template->getTitle() . "\n"; } ``` -------------------------------- ### Create and Send a Signature Request Source: https://github.com/hellosign/hellosign-php-sdk/blob/v3/README.md Example code for creating a new signature request, setting its properties like title, subject, message, adding signers and CC recipients, and attaching files. ```php $request = new HelloSign\SignatureRequest; $request->enableTestMode(); $request->setTitle('NDA with Acme Co.'); $request->setSubject('The NDA we talked about'); $request->setMessage('Please sign this NDA and let\'s discuss.'); $request->addSigner('jack@example.com', 'Jack'); $request->addSigner('jill@example.com', 'Jill'); $request->addCC('lawyer@example.com'); $request->addFile('nda.pdf'); //Adding file from local $response = $client->sendSignatureRequest($request); ``` -------------------------------- ### Set Form Fields Per Document Source: https://github.com/hellosign/hellosign-php-sdk/blob/v3/README.md Example of how to define and set form fields for each document within a signature request, specifying field properties like type, position, and requirements. ```php $request->setFormFieldsPerDocument( array( array( //document 1 array( //field 1 "api_id"=> $random_prefix . "_1", "name"=> "", "type"=> "text", "x"=> 112, "y"=> 328, "width"=> 100, "height"=> 16, "required"=> true, "signer"=> 0 ), array( //field 2 "api_id"=> $random_prefix . "_2", "name"=> "", "type"=> "signature", "x"=> 530, "y"=> 415, "width"=> 150, "height"=> 30, "required"=> true, "signer"=> 1 ), ), ) ); ``` -------------------------------- ### Configure HelloSign Client Source: https://github.com/hellosign/hellosign-php-sdk/blob/v3/README.md Demonstrates how to initialize the HelloSign Client class using different authentication methods: API key, email/password, and OAuth token. ```php $client = new HelloSign\Client($apikey); $client = new HelloSign\Client($email_address, $password); $client = new HelloSign\Client($oauth_token); //instance of HelloSign\OAuthToken ``` -------------------------------- ### Enable OAuth and Manage Tokens Source: https://github.com/hellosign/hellosign-php-sdk/blob/v3/README.md Details the process of enabling OAuth for HelloSign integration. It covers creating an account if it doesn't exist, requesting an OAuth token using authorization code, storing and refreshing tokens, and using the token to authenticate the client. ```php // If the account does not exist if !($client->isAccountValid($email)) { // Create new account $account = $client->createAccount( new HelloSign\Account($email), $client_id, $client_secret ); // Get OAuth token $token = $account->getOAuthData(); } else { // Create the OAuthTokenRequest object $oauth_request = new HelloSign\OAuthTokenRequest(array( 'code' => $code, 'state' => $state, 'client_id' => $client_id, 'client_secret' => $client_secret )); // Request OAuth token for the first time $token = $client->requestOAuthToken($oauth_request); } // Export token to array, store it to use later $hellosign_oauth = $token->toArray(); // Populate token from array $token = new HelloSign\OAuthToken($hellosign_oauth); // Refresh token if it expired $client->refreshOAuthToken($token); // Provide the user's OAuth access token to the client $client = new HelloSign\Client($token); ``` -------------------------------- ### Display API Warnings Source: https://github.com/hellosign/hellosign-php-sdk/blob/v3/README.md Shows how to access and display any warnings returned by the HelloSign API. It retrieves a list of signature requests and then prints any associated warnings. ```php $response = $this->client->getSignatureRequests(); print_r($response->getWarnings()); ``` -------------------------------- ### MIT License Source: https://github.com/hellosign/hellosign-php-sdk/blob/v3/README.md The MIT License (MIT) grants users the freedom to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the software. It requires that the original copyright notice and permission notice be included in all copies or substantial portions of the Software. The software is provided 'as is' without warranty. ```text The MIT License (MIT) Copyright (C) 2014 hellosign.com Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ``` -------------------------------- ### Create Embedded Template Draft Source: https://github.com/hellosign/hellosign-php-sdk/blob/v3/README.md Demonstrates how to create a draft for an embedded template. This involves creating a Template object, setting its properties like test mode, client ID, file, title, message, and signer roles, and then sending it to create the draft. ```php $template = new HelloSign\Template(); $template->enableTestMode(); $template->setClientId($client_id); $template->addFile('nda.pdf'); $template->setTitle('Test Title'); $template->setSubject('Test Subject'); $template->setMessage('Test Message'); $template->addSignerRole('Test Role'); $template->addMetadata('custom_id', '1234'); $response = $client->createEmbeddedDraft($template); ``` -------------------------------- ### Configure Text Tags for Signature Requests Source: https://github.com/hellosign/hellosign-php-sdk/blob/v3/README.md Shows how to enable and configure the use of Text Tags within documents for signature requests. ```php $request->setUseTextTags(true); $request->setHideTextTags(true); ``` -------------------------------- ### Create Signature Request from Template Source: https://github.com/hellosign/hellosign-php-sdk/blob/v3/README.md Demonstrates how to create a signature request using a template. It sets up a TemplateSignatureRequest object, enables test mode, specifies the template ID, subject, message, and defines signers and CC recipients. Custom field values can also be set. ```php $request = new HelloSign\TemplateSignatureRequest; $request->enableTestMode(); $request->setTemplateId($template->getId()); $request->setSubject('Purchase Order'); $request->setMessage('Glad we could come to an agreement.'); $request->setSigner('Client', 'george@example.com', 'George'); $request->setCC('Accounting', 'accounting@example.com'); $request->setCustomFieldValue('Cost', '$20,000'); $response = $client->sendTemplateSignatureRequest($request); ``` -------------------------------- ### Create Unclaimed Draft for Embedded Request Source: https://github.com/hellosign/hellosign-php-sdk/blob/v3/README.md Explains how to create an unclaimed draft that can be used for embedded signing requests. It shows the creation of an UnclaimedDraft object and how to obtain the claim URL for embedding. ```php $draft = new HelloSign\UnclaimedDraft($request, $client_id); // optionally change it to a self-signing draft with $draft->setType("send_document"); $response = $client->createUnclaimedDraft($draft); // Store it to use with the embedded.js HelloSign.open() call $sign_url = $response->getClaimUrl(); ``` -------------------------------- ### Access Signature Request Fields Source: https://github.com/hellosign/hellosign-php-sdk/blob/v3/README.md Shows how to access fields from a signature request object using magic methods or convert the object to an array. ```php $signature_request->title; $signature_request->toArray(); ``` -------------------------------- ### Git Commit Check for Whitespace Source: https://github.com/hellosign/hellosign-php-sdk/blob/v3/CONTRIBUTING.md This command checks for unnecessary whitespace in your staged changes before committing. It helps maintain code quality by identifying potential formatting issues. ```git git diff --check ``` -------------------------------- ### Create Embedded Signature Request Source: https://github.com/hellosign/hellosign-php-sdk/blob/v3/README.md Illustrates the process of creating an embedded signature request for in-app signing. It involves creating a SignatureRequest or TemplateSignatureRequest, converting it to an EmbeddedSignatureRequest, sending it, and then retrieving the signing URL. ```php // Create the SignatureRequest or TemplateSignatureRequest object $request = ... // Turn it into an embedded request $embedded_request = new HelloSign\EmbeddedSignatureRequest($request, $client_id); // Send it to HelloSign $response = $client->createEmbeddedSignatureRequest($embedded_request); // Grab the signature ID for the signature page that will be embedded in the // page (for the demo, we'll just use the first one) $signatures = $response->getSignatures(); $signature_id = $signatures[0]->getId(); // Retrieve the URL to sign the document $response = $client->getEmbeddedSignUrl($signature_id); // Store it to use with the embedded.js HelloSign.open() call $sign_url = $response->getSignUrl(); ``` -------------------------------- ### Add Remote File URL to Signature Request Source: https://github.com/hellosign/hellosign-php-sdk/blob/v3/README.md Demonstrates how to add a file to a signature request using a URL to a remote file instead of a local file. ```php $request->addFileURL('PUBLIC_URL_TO_YOUR_FILE'); ``` -------------------------------- ### Check Signature Request Status Source: https://github.com/hellosign/hellosign-php-sdk/blob/v3/README.md Shows how to retrieve the status of a signature request using its ID. It checks if the request is complete and iterates through signatures to display their status codes. ```php $response = $client->getSignatureRequest($signature_request_id); if ($response->isComplete()) { echo 'All signers have completed the request.'; } else { foreach ($response->getSignatures() as $signature) { echo $signature->getStatusCode() . "\n"; } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.