Friday, May 22, 2015

Easy & secure way to do digital signature on any online document in php

Easy way for Digital Signature:

For easily digital signature on any online document you have to do some following steps:

1. Create an account on Hellosign.com . Due to this you'll get an API Key.

2. After creating an account create a test app from here. . Due to this you'll get a client id.

Now using this install its package in your project.

Now write this code in your php file.

        require_once 'vendor/autoload.php';
        $client = new HelloSign\Client('YOUR_API_KEY');
        $request = new HelloSign\SignatureRequest;
        $request->enableTestMode();
        $request->setSubject('SUBJECT_NAME');
        $request->setMessage('SUBJECT_MESSAGE');
        $request->addSigner('YOUR_EMAIL', 'Me');
        $request->addFile('PATH_OF_FILE');

        $client_id = 'YOUR_CLIENT_ID';
        $embedded_request = new HelloSign\EmbeddedSignatureRequest($request, $client_id);
        $response = $client->createEmbeddedSignatureRequest($embedded_request);
        $signature = $response->signatures[0]->signature_id;
        $response = $client->getEmbeddedSignUrl($signature);
 

<script type="text/javascript" src="//s3.amazonaws.com/cdn.hellofax.com/js/embedded.js"></script>
<script type="text/javascript">
    window.onload = function() {
    HelloSign.init("YOUR_CLIENT_ID");
    HelloSign.open({
        url: "<?php echo $response->sign_url; ?>",
        allowCancel: true,
        messageListener: function (eventData) {
            alert("HelloSign event received");
        }
    });
    }
</script>

Run this file and see the magic.

Thanks


No comments:

Post a Comment