Ramprasad_appdev

attempting to use Simple PHP Web Application

0 votes
Hi. I am trying to implement the sample code provided at https://www.esignlive.com/blog/esignlive-how-to-creating-a-simple-php-web-application/ I have changed the API Key to the API key in my account and url . private $url = “https://sandbox.e-signlive.ca/api”; private $key = “XXXXXXXXXX”; private $packageAppend = “/packages/”; private $tokenAppend = “/signerAuthenticationTokens/”; When I attempt to use this sample code, i receive the following error: “Unauthorized Access We’re sorry. Your session may have expired. Please try again. If you receive this message multiple times, please contact support.”

Approved Answer

Reply to: attempting to use Simple PHP Web Application

1 votes
Hi there, I've made some changes to the code. Unfortunately, we are experiencing some issues with our Code Shares. I've temporarily uploaded the project on GitHub where you can get the latest version:
git clone https://github.com/hhaidary/sample-php-app
Haris Haidary OneSpan Technical Consultant

Reply to: attempting to use Simple PHP Web Application

0 votes
Did you ajust the Url ? Did you put the right api in ? ( not the XXXX-XXXX)

Reply to: attempting to use Simple PHP Web Application

1 votes
This is working fine but when i send different document then i receive the following error: “Unauthorized Access We’re sorry. Your session may have expired. Please try again. If you receive this message multiple times, please contact support.” what is MULTIPART_BOUNDARY ? Is it always the same value ----WebKitFormBoundary7MA4YWxkTrZu0gW ? If not then how i find it? How to integrate eSignLive Fields via Text Tags in php?

Reply to: attempting to use Simple PHP Web Application

0 votes
The php form app uses the Document Extraction feature to position signatures on the document. If you change the document, you'll also need to modify the code accordingly. If you want to use text tags, you can follow the guide below on how to do so: https://developer.esignlive.com/guides/feature-guides/text-tags-extraction/#rest-api
Haris Haidary OneSpan Technical Consultant

Reply to: attempting to use Simple PHP Web Application

0 votes
if i send html file alternative of pdf file

Reply to: attempting to use Simple PHP Web Application

0 votes
Ok, fine . I upload my pdf file. Which i want to send my customer. I upload the pdf and which field I want to variable for this I upload some png please answer me

Attachments
test-4.pdf87.95 KB
page1.png124.66 KB
page2.png217.64 KB
page3.png196.55 KB

Reply to: attempting to use Simple PHP Web Application

0 votes
all page are marked with red color in the next three screen shoot please help me

Reply to: attempting to use Simple PHP Web Application

0 votes
Hi, I've updated your document with some sample text tags and I've included the JSON payload to go with it. From this, you should be able to change the PHP app accordingly.
{
  "documents": [
    {
      "id": "sample-contract",
      "name": "Test Document",
      "extract": true,
      "data": {
        "esl_doc_extract_type": 1
      }
    }
  ],
  "status": "SENT",
  "type": "PACKAGE",
  "roles": [
    {
      "id": "signer1",
      "type": "SIGNER",
      "signers": [
        {
          "email": "[email protected]",
          "firstName": "John",
          "lastName": "Smith",
          "id": "signer1"
        }
      ],
      "name": "signer1"
    }
  ],
  "name": "Text Tags Example Package"
}
Haris Haidary OneSpan Technical Consultant

Attachments

Reply to: attempting to use Simple PHP Web Application

0 votes
please check First, I create package, for that I send this JSON data { "documents": [ { "id": "sample-contract", "name": "Test Document", "extract": true, "data": { "esl_doc_extract_type": 1 } } ], "status": "DRAFT", "type": "PACKAGE", "roles": [ { "id": "signer1", "type": "SIGNER", "signers": [ { "email": "[email protected]", "firstName": "Hemanta", "lastName": "Kundu", "id": "signer1" } ], "name": "signer1" } ], "name": "Text Tags Example Package" } ENDPOINT => https://sandbox.e-signlive.ca/api/packages HTTP Method => POST Content Type => multipart/form-data Accept => application/json Authentication => Basic. $my api key and also get the packegeid looks like { "id": "LR_P239G0Xw8hLXXEk8OOgnaVNM=" } I think first process is ok

Reply to: attempting to use Simple PHP Web Application

0 votes
SECOND STEP =>UPLOAD DOCUMENT public function buildDocument($packageId, $firstName, $lastName, $address, $city, $state, $zip, $country, $phoneNumber, $emailAddress, $company, $policyNumber) { $build = array( 'fields' => array( array( 'value' => $firstName, 'name' => 'first_name', ) , array( 'value' => $lastName, 'name' => 'last_name', ) , array( 'value' => $address, 'name' => 'address', ) , array( 'value' => $city, 'name' => 'city', ) , array( 'value' => $state, 'name' => 'state', ) , array( 'value' => $zip, 'name' => 'zip', ) , array( 'value' => $country, 'name' => 'country', ) , array( 'value' => $phoneNumber, 'name' => 'phone_number', ) , array( 'value' => $emailAddress, 'name' => 'email', ) , array( 'value' => $company, 'name' => 'company', ) , array( 'value' => $policyNumber, 'name' => 'policy_number', ) , ) , 'extract' => true, 'name' => 'Test Document', 'id' => 'sample-contract' ); $documentJSON = json_encode($build); $postdata = "--" . MULTIPART_BOUNDARY . "\r\n"; $postdata .= "Content-Disposition: form-data; name=\"file\"; filename=\"sample_contract1.pdf\"\r\n"; $postdata .= "Content-Type: application/pdf" . "\r\n\r\n"; $postdata .= Storage::get("documents\sample_contract1.pdf"); $postdata .= "\r\n\r\n"; $postdata .= "--" . MULTIPART_BOUNDARY . "\r\n"; $postdata .= "Content-Disposition: form-data; name=\"payload\"\r\n\r\n"; $postdata .= $documentJSON; $postdata .= "\r\n\r\n"; $postdata .= "--" . MULTIPART_BOUNDARY . "--\r\n"; $status = $this->sendRequest($this->packageAppend . $packageId['id'] . '/documents', $documentJSON, $postdata, 'multipart/form-data; boundary=' . MULTIPART_BOUNDARY); return $status; } for this I use previous day pdf document which you send to me and I get follwoing result "{"status":"","description":"","id":"sample-contract","approvals":[],"pages":[{"id":"","height":1030.0,"left":0.0,"width":796.0,"top":0.0,"index":0,"version":0},{"id":"","height":1030.0,"left":0.0,"width":796.0,"top":0.0,"index":1,"version":0}],"extract":true,"external":null,"signedHash":null,"extractionTypes":[],"tagged":false,"signerVerificationToken":null,"data":{"ese_document_texttag_extract_needed":"false"},"index":1,"fields":[],"name":"Test Document","size":200501} â—€" and in my account I see the uploaded document

Reply to: attempting to use Simple PHP Web Application

0 votes
Third process => Send Package public function buildSend($packageId) { $build = array( 'status' => 'SENT' ); $sendJSON = json_encode($build); $this->sendRequest($this->packageAppend . $packageId['id'], $sendJSON, NULL, 'application/json'); return NULL; } Endpoint= https://sandbox.e-signlive.ca/api/packages/LR_P239G0Xw8hLXXEk8OOgnaVNM=

Reply to: attempting to use Simple PHP Web Application

0 votes
fourth process =>Sender signs consent and contract documents In this process I want to remove the default document public function buildSign($packageId) { $build = array( 'documents' => array( array( 'id' => 'default-consent', 'name' => 'Electronic Disclosures and Signatures Consent' ) , array( 'id' => 'sample-contract', 'name' => 'Test Document' ) ) ); $signJSON = json_encode($build); $signatureAppend = $this->packageAppend . $packageId['id'] . '/documents/signed_documents'; $this->sendRequest($signatureAppend, $signJSON, NULL, 'application/json'); return NULL; }

Reply to: attempting to use Simple PHP Web Application

0 votes
Fifth process => Get a session token and in this process i get 'NULL" value public function buildToken($packageId) { $build = array( 'packageId' => $packageId['id'], 'signerId' => 'signer1' ); $tokenJSON = json_encode($build); $token = json_decode($this->sendRequest($this->tokenAppend, $tokenJSON, NULL, 'application/json'), true); return $token; } please help me to overcome this problem

Reply to: attempting to use Simple PHP Web Application

0 votes
Hi all, when using postman then text tag is working. But in my code it is not working showing this error {"code":500,"messageKey":"error.internal.default","message":"Unexpected error. We apologize for any inconvenience this may have caused you, please try again. If the problem persists, please contact our support team.","name":"Unhandled Server Error"}

Reply to: attempting to use Simple PHP Web Application

0 votes
MULTIPART_BOUNDARY = '----WebKitFormBoundary7MA4YWxkTrZu0gW' my code is $build= array( 'documents' =>array( array( 'id' => 'sample-contract', 'name' => 'Test Document', 'extract' => true, 'data' => array( 'esl_doc_extract_type' => 1 ) ) ), 'status' => 'SENT', 'type' => 'PACKAGE', 'roles' => array( array( 'id' => 'signer1', 'type' => 'SIGNER', 'signers' => array( array( 'email' => '[email protected]', 'firstName' => 'Hemanta', 'lastName' => 'kundu', 'id' => 'signer1' ) ), 'name' => 'signer1' ) ), 'name' => 'Text Tags Example Package' ); $packageJSON = json_encode($build); $postdata = "--" . MULTIPART_BOUNDARY . "\r\n"; $postdata .= "Content-Disposition: form-data; name=\"file\"; filename=\"sample_contract1.pdf\"\r\n"; $postdata .= "Content-Type: application/pdf" . "\r\n\r\n"; $postdata .= Storage::get("documents/sample_contract1.pdf");//file_get_contents $postdata .= "\r\n\r\n"; $postdata .= "--" . MULTIPART_BOUNDARY . "\r\n"; $postdata .= "Content-Disposition: form-data; name=\"payload\"\r\n\r\n"; $postdata .= $packageJSON; $postdata .= "\r\n\r\n"; $postdata .= "--" . MULTIPART_BOUNDARY . "--\r\n"; $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => "https://sandbox.e-signlive.ca/api/packages", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => $postdata, CURLOPT_HTTPHEADER => array( "Accept: application/json", "Authorization: Basic XXXXX", "Content-Type: multipart/form-data", "content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW" ) )); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:" . $err; } else { echo $response; } and sample_contract add in upload section

Attachments

Reply to: attempting to use Simple PHP Web Application

0 votes
Thanks for sharing this. I will look into it and get back to you.
Haris Haidary OneSpan Technical Consultant

Reply to: attempting to use Simple PHP Web Application

0 votes
Here's a code:
array(
array(
'id' => 'sample-contract',
'name' => 'Test Document',
'extract' => true,
'data' => array(
'esl_doc_extract_type' => 1
)
)
),
'status' => 'SENT',
'type' => 'PACKAGE',
'roles' => array(
array(
'id' => 'signer1',
'type' => 'SIGNER',
'signers' => array(
array(
'email' => '[email protected]',
'firstName' => 'Hemanta',
'lastName' => 'kundu',
'id' => 'signer1'
)
),
'name' => 'signer1'
)
),
'name' => 'Text Tags Example Package'
);


$api_headers = array(
        "Authorization: Basic XXXXXXXXXXXXX",
        "Accept: application/json; esl-api-version=11.10",
        "Content-Type: multipart/form-data; boundary=\"" . MULTIPART_BOUNDARY . "\"",
    );

$postdata = "--" . MULTIPART_BOUNDARY . "\r\n";
$postdata .= "Content-Disposition: form-data; name=\"file\"; filename=\"sample_contract1.pdf\"\r\n\r\n";
$postdata .= file_get_contents("sample_contract1.pdf");
$postdata .= "\r\n\r\n";
$postdata .= "--" . MULTIPART_BOUNDARY . "\r\n";
$postdata .= "Content-Disposition: form-data; name=\"payload\"\r\n\r\n";
$postdata .= json_encode($build);
$postdata .= "\r\n\r\n";
$postdata .= "--" . MULTIPART_BOUNDARY . "--\r\n";

$curl = curl_init(API_URL);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POST          , true);
curl_setopt($curl, CURLOPT_POSTFIELDS    , $postdata);
curl_setopt($curl, CURLOPT_HTTPHEADER    , $api_headers);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_exec($curl);
$response = curl_multi_getcontent($curl);
curl_close($curl);

echo mb_convert_encoding(print_r(json_decode($response, true), true), 'CP932', 'UTF-8');
Haris Haidary OneSpan Technical Consultant

Reply to: attempting to use Simple PHP Web Application

0 votes
Its working. Great! Thank you very much Haris. My client also has congratulated you.

Reply to: attempting to use Simple PHP Web Application

0 votes
For field injection in the PDF how to modify the PDF? I want to add field injection in the same PDF for insert some data. I follow this link https://developer.esignlive.com/guides/feature-guides/field-injection/ but don't understand how to modify my PDF file accordingly. Please help me. For that, I upload my PDF document with screenshot. the problem is marked in red colour. Please tell me the process how to modify my document. Otherwise, in future if require to customize the PDF then we facing a greet problem. Please help me.

Attachments

Reply to: attempting to use Simple PHP Web Application

0 votes
Hey Haris, Thanks, I create the from field. But I have another issue that perhaps you can help me with. I follow this link https://developer.esignlive.com/guides/feature-guides/field-injection/ for signature field, how to create signature field and date field in pdf?

Reply to: attempting to use Simple PHP Web Application

0 votes
Hey Haris, Thanks, I send the document successfully. But I have another issue that perhaps you can help me with. When I send the document to e-mail address its showing the English language. But I want to change this language sometime in English and other Language with my database. How can I do it? please help me.

Reply to: attempting to use Simple PHP Web Application

0 votes
Hi Ramprasad, If you are talking about configure the language of notifications which OneSpan Sign would send to every recipients whose signature is pending, yes, you can follow our Configure Package Language feature, here's the guidance. The language is set in a package/transaction level which means every recipient would receive the same email notification. Hope you find this reply helpful!

Duo Liang OneSpan Evangelism and Partner Integrations Developer


Reply to: attempting to use Simple PHP Web Application

0 votes
Hi Haris, I've tried this new code example and this is what I'm getting:
Array
(
    [technical] => Could not find user with uid 'XXXXX'
    [messageKey] => error.notFound.userNotFound
    [code] => 404
    [message] => The specified user cannot be found.
    [name] => Resource Not Found
)
Not sure if I had to put the real uid. Before that, I tried the code in https://www.esignlive.com/blog/esignlive-how-to-create-and-send-a-package-with-rest-in-php and the result is either error.validation.sendPackage.noApprovals or error.validation.verifyDocument.hasNeedAppearancesFlag. With all these different responses I'm not sure which one should I stick to. Thank you in advance for your help. Regards, Sina P.S. The API key that I'm having is working fine with https://sandbox.esignlive.com/api/packages/overview

Reply to: attempting to use Simple PHP Web Application

0 votes
Hi Sina, About the code in https://www.esignlive.com/blog/esignlive-how-to-create-and-send-a-package-with-rest-in-php, I think in $json array, within the 'documents' attribute, you could add one more line here:
'documents' => array(
		array(
			'name' => 'Sample Contract',
			'id' => 'contract',
			'extract'=>true,
		)
)
The feature behind this example is Document Extraction. The pdf file is reused from the other php example, so you can see many pdf forms in this document don't have other usages. These forms are for the Field Injection Feature in that example. About your first question, could you provide more information about reference you are following and the API call you are using with the request payload? Because from what I understood, that's an example for user to input personal information, generate the package automatically and then embedding the signing ceremony into an iFrame. I didn't receive any response payload nor encountered anything related to the 'uid'. Thanks for your post and help this could help you!

Duo Liang OneSpan Evangelism and Partner Integrations Developer


Reply to: attempting to use Simple PHP Web Application

0 votes

Hi Liang, I actually have extract=>true in my code. I've created a new post explaining the goal I'm trying to achieve. About the first question, I used Haris's new example in this post:

< ?php
define("API_URL", "https://sandbox.e-signlive.ca/api/packages");
define("MULTIPART_BOUNDARY", "----WebKitFormBoundary7MA4YWxkTrZu0gW");

$build= array(
'documents' =>array(
array(
'id' => 'sample-contract',
'name' => 'Test Document',
'extract' => true,
'data' => array(
'esl_doc_extract_type' => 1
)
)
),
'status' => 'SENT',
'type' => 'PACKAGE',
'roles' => array(
array(
'id' => 'signer1',
'type' => 'SIGNER',
'signers' => array(
array(
'email' => '[email protected]',
'firstName' => 'Hemanta',
'lastName' => 'kundu',
'id' => 'signer1'
)
),
'name' => 'signer1'
)
),
'name' => 'Text Tags Example Package'
);


$api_headers = array(
        "Authorization: Basic XXXXXXXXXXXXX",
        "Accept: application/json; esl-api-version=11.10",
        "Content-Type: multipart/form-data; boundary=\"" . MULTIPART_BOUNDARY . "\"",
    );

$postdata = "--" . MULTIPART_BOUNDARY . "\r\n";
$postdata .= "Content-Disposition: form-data; name=\"file\"; filename=\"sample_contract1.pdf\"\r\n\r\n";
$postdata .= file_get_contents("sample_contract1.pdf");
$postdata .= "\r\n\r\n";
$postdata .= "--" . MULTIPART_BOUNDARY . "\r\n";
$postdata .= "Content-Disposition: form-data; name=\"payload\"\r\n\r\n";
$postdata .= json_encode($build);
$postdata .= "\r\n\r\n";
$postdata .= "--" . MULTIPART_BOUNDARY . "--\r\n";

$curl = curl_init(API_URL);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POST          , true);
curl_setopt($curl, CURLOPT_POSTFIELDS    , $postdata);
curl_setopt($curl, CURLOPT_HTTPHEADER    , $api_headers);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_exec($curl);
$response = curl_multi_getcontent($curl);
curl_close($curl);

echo mb_convert_encoding(print_r(json_decode($response, true), true), 'CP932', 'UTF-8');

And the attached file. Thank you, Sina


Attachments

Reply to: attempting to use Simple PHP Web Application

2 votes
Hi Sina, Please make sure you are using the right environment tied to your API key.(sandbox.e-signlive.ca vs sandbox.esignlive.com) Then, haris's code above is using a Text Tag Feature, where pdf forms are not needed.(only use esl grammar to let OneSpan Sign know the size, type and where you want the field to put). While the attachment you gave is not using esl grammar. I would talk to you in your new post and hope this could help you in this part!

Duo Liang OneSpan Evangelism and Partner Integrations Developer


Reply to: attempting to use Simple PHP Web Application

0 votes
Thank you very much Liang.

Reply to: attempting to use Simple PHP Web Application

0 votes
You are welcome, just let us know if you have any other issues. :) Duo

Duo Liang OneSpan Evangelism and Partner Integrations Developer


Hello! Looks like you're enjoying the discussion, but haven't signed up for an account.

When you create an account, we remember exactly what you've read, so you always come right back where you left off