您好,我尝试使用 DocuSign 的嵌入式签名功能对文档进行签名,但是当我发送请求时,屏幕签名文档没有出现,它会将我重定向到 URL 参数为event=ttl_expired的页面。
我知道 URL 令牌的 ttl(生命周期)= 5 分钟,有人可以帮我吗?
您好,我尝试使用 DocuSign 的嵌入式签名功能对文档进行签名,但是当我发送请求时,屏幕签名文档没有出现,它会将我重定向到 URL 参数为event=ttl_expired的页面。
我知道 URL 令牌的 ttl(生命周期)= 5 分钟,有人可以帮我吗?
URL 令牌仅在 5 分钟内有效。如果您被重定向到 URL 参数为event=ttl_expired的屏幕,则这意味着您正在尝试从过期的 URL 令牌访问签名工作流。
当 URL 令牌过期时,您需要生成一个新令牌。你看过 DocuSign 的 API 演练吗?DocuSign 的 REST API 有 9 个常见用例,其中之一是嵌入式签名。每个演练都有代码向您展示如何用 6 种不同的语言(PHP、JavaScript、Java、C#、Objective-C、Python)完成该任务。
请参阅此处了解演练:http: //iodocs.docusign.com/APIWalkthroughs
例如,由于 PHP 很容易从命令行运行,因此这里是一个完整的 PHP 程序,用于生成用于签名的有效 URL 令牌,取自Embedded Signing API Walkthrough。只需输入您的凭据和您帐户中的有效模板 ID,这将适用于您:
<?php
// Input your info:
$integratorKey = '...';
$email = '...@....com';
$password = '...';
$name = "John Doe";
// copy the templateId of an existing template here
$templateId = "C9D9D181-CE57-.....................";
// construct the authentication header:
$header = "<DocuSignCredentials><Username>" . $email . "</Username><Password>" . $password . "</Password><IntegratorKey>" . $integratorKey . "</IntegratorKey></DocuSignCredentials>";
/////////////////////////////////////////////////////////////////////////////////////////////////
// STEP 1 - Login (retrieves baseUrl and accountId)
/////////////////////////////////////////////////////////////////////////////////////////////////
$url = "https://demo.docusign.net/restapi/v2/login_information";
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("X-DocuSign-Authentication: $header"));
$json_response = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ( $status != 200 ) {
echo "error calling webservice, status is:" . $status;
exit(-1);
}
$response = json_decode($json_response, true);
$accountId = $response["loginAccounts"][0]["accountId"];
$baseUrl = $response["loginAccounts"][0]["baseUrl"];
curl_close($curl);
//--- display results
echo "accountId = " . $accountId . "\nbaseUrl = " . $baseUrl . "\n";
/////////////////////////////////////////////////////////////////////////////////////////////////
// STEP 2 - Create an envelope with an Embedded recipient (uses the clientUserId property)
/////////////////////////////////////////////////////////////////////////////////////////////////
$data = array("accountId" => $accountId,
"emailSubject" => "Hello World!",
"emailBlurb" => "This comes from PHP",
"templateId" => $templateId,
"templateRoles" => array(
array( "email" => $email, "name" => $name, "roleName" => "Signer1", "clientUserId" => "1001" )),
"status" => "sent");
$data_string = json_encode($data);
$curl = curl_init($baseUrl . "/envelopes" );
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string),
"X-DocuSign-Authentication: $header" )
);
$json_response = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ( $status != 201 ) {
echo "error calling webservice, status is:" . $status . "\nerror text is --> ";
print_r($json_response); echo "\n";
exit(-1);
}
$response = json_decode($json_response, true);
$envelopeId = $response["envelopeId"];
curl_close($curl);
//--- display results
echo "Envelope created! Envelope ID: " . $envelopeId . "\n";
/////////////////////////////////////////////////////////////////////////////////////////////////
// STEP 3 - Get the Embedded Singing View
/////////////////////////////////////////////////////////////////////////////////////////////////
$data = array("returnUrl" => "http://www.docusign.com/devcenter",
"authenticationMethod" => "None", "email" => $email,
"userName" => $name, clientUserId => "1001"
);
$data_string = json_encode($data);
$curl = curl_init($baseUrl . "/envelopes/$envelopeId/views/recipient" );
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string),
"X-DocuSign-Authentication: $header" )
);
$json_response = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ( $status != 201 ) {
echo "error calling webservice, status is:" . $status . "\nerror text is --> ";
print_r($json_response); echo "\n";
exit(-1);
}
$response = json_decode($json_response, true);
$url = $response["url"];
//--- display results
echo "Embedded URL is: \n\n" . $url . "\n\nNavigate to this URL to start the embedded signing view of the envelope\n";
?>