Friday, June 12, 2015

How to get Signed document from HelloSign API in php?

Get Signed Document in HelloSign:

In my previous blog, you can do a digital signature. But at that time when we download that signed document, sometimes sign was not implemented on that document.

This is done because, Hellosign API takes some time to implement sign on that document.

For download a signed document:

For this firstly you have to set a callback URL.

In my case i am using test.php.

Write down in test.php  without underline
Hello API Event Received

And after sending sign request when to redirect to another page.
Then write this code on this another page.

<?php
try {
require_once 'vendor/autoload.php';
$client = new HelloSign\Client('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
$account = new HelloSign\Account;
$signature = Yii::app()->session['signature_req_id'];
$dest_file_path = 'PATH_OF_FILE_WHERE_TO_SAVE_WITH_NAME';
$account->setCallbackUrl'PATH_OF_test.php');
$resp = $client->updateAccount($account);
$response = $client->getSignatureRequest($signature);
if ($response->isComplete()) {
$client->getFiles($signature, $dest_file_path, HelloSign\SignatureRequest::FILE_TYPE_PDF);
} else {
execCommand(); //call this function
}
} catch (Exception $e) {
echo 'Error Occured ' . $e;
}





    public function execCommand()
    {
        require_once 'vendor/autoload.php';
        $client = new HelloSign\Client('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');

        $signature = Yii::app()->session['signature_req_id'];
        $dest_file_path = '
PATH_OF_FILE_WHERE_TO_SAVE_WITH_NAME';
        $response = $client->getSignatureRequest($signature);
        if ($response->isComplete()) {
            $client->getFiles($signature, $dest_file_path, HelloSign\SignatureRequest::FILE_TYPE_PDF);
            return true;
        } else {
            $this->execCommand(); //recursion function
        }
    }


?>



Thanks

1 comment:

  1. Thank you for the valuable information

    Being a free electronic signature software provider, I usually recommend to all the modern generation for creating an online signature for their business, enterprises, real estate business and so on. Don't wait for any person. You can use this application on your devices. Search WeSignature on Google and try it free of cost. It is a best e signature software for small business, electronic signature real estate contracts, electronic signature for insurance and so on industries.

    Must Try this - A Free Electronic Signature Software WeSignature.

    ReplyDelete