docusignapi - 在此处签名选项卡仅适用于一位签名者
问题描述
我的 API 有问题。我有多个签名者,每个签名者都有自己的签名选项卡,但只有第一个签名者能够签名,而无需手动放置签名选项卡。我正在使用 Docusign 示例代码的修改版本。有谁知道可能出了什么问题?
这是代码:
<?php
# PHP Quick start example: Send signing request by email.
# Copyright (c) 2018 by DocuSign, Inc.
# License: The MIT License -- https://opensource.org/licenses/MIT
require_once('vendor/autoload.php');
require_once('vendor/docusign/esign-client/autoload.php');
function send_document_for_signing(){
#
# The document $fileNamePath will be sent to be signed by <signer_name>
# Settings
# Fill in these constants
#
# Obtain an OAuth access token from https://developers.docusign.com/oauth-token-generator
$accessToken = '**ACCESS TOKEN**';
# Obtain your accountId from demo.docusign.com -- the account id is shown in the drop down on the
# upper right corner of the screen by your picture or the default picture.
$accountId = '**ACCOUNT ID**';
# Recipient Information:
# The document you wish to send. Path is relative to the root directory of this repo.
$fileNamePath = 'demo_documents/World_Wide_Corp_lorem.pdf';
# The API base_path
$basePath = 'https://demo.docusign.net/restapi';
# Constants
$appPath = getcwd();
#
# Step 1. The envelope definition is created.
# One signHere tab is added.
# The document path supplied is relative to the working directory
#
# Create the component objects for the envelope definition...
$contentBytes = file_get_contents($appPath . "/" . $fileNamePath);
$base64FileContent = base64_encode ($contentBytes);
# create the DocuSign document object
$document = new DocuSign\eSign\Model\Document([
'document_base64' => $base64FileContent,
'name' => 'Example document', # can be different from actual file name
'file_extension' => 'pdf', # many different document types are accepted
'document_id' => '1' # a label used to reference the doc
]);
# The signer object
$signer = new DocuSign\eSign\Model\Signer([
'email' => '**mail1**', 'name' => '**name1**', 'recipient_id' => "1", 'routing_order' => "1",
]);
$signer2 = new DocuSign\eSign\Model\Signer([
'email' => '**mail2**', 'name' => '**name2**', 'recipient_id' => "2", 'routing_order' => "2",
]);
# DocuSign SignHere field/tab object
$signHere = new DocuSign\eSign\Model\SignHere([
'document_id' => '1', 'page_number' => '1', 'recipient_id' => '1',
'tab_label' => 'SignHereTab', 'x_position' => '195', 'y_position' => '147'
]);
$signHere2 = new DocuSign\eSign\Model\SignHere([
'document_id' => '1', 'page_number' => '1', 'recipient_id' => '2',
'tab_label' => 'SignHereTab', 'x_position' => '230', 'y_position' => '180'
]);
# Add the tabs to the signer object
# The Tabs object wants arrays of the different field/tab types
$signer->setTabs(new DocuSign\eSign\Model\Tabs(['sign_here_tabs' => [$signHere2, $signHere]]));
# Next, create the top level envelope definition and populate it.
$envelopeDefinition = new DocuSign\eSign\Model\EnvelopeDefinition([
'email_subject' => "Please sign this document",
'documents' => [$document], # The order in the docs array determines the order in the envelope
# The Recipients object wants arrays for each recipient type
'recipients' => new DocuSign\eSign\Model\Recipients(['signers' => [$signer, $signer2]]),
'status' => "sent" # requests that the envelope be created and sent.
]);
#
# Step 2. Create/send the envelope.
#
$config = new DocuSign\eSign\Configuration();
$config->setHost($basePath);
$config->addDefaultHeader("Authorization", "Bearer " . $accessToken);
$apiClient = new DocuSign\eSign\Client\ApiClient($config);
$envelopeApi = new DocuSign\eSign\Api\EnvelopesApi($apiClient);
$results = $envelopeApi->createEnvelope($accountId, $envelopeDefinition);
return $results;
};
# Mainline
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
try {
$results = send_document_for_signing();
?>
<html lang="en">
<body>
<h4>Results</h4>
<p>Status: <?= $results['status'] ?>, Envelope ID: <?= $results['envelope_id'] ?></p>
</body>
</html>
<?php
} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
if ($e instanceof DocuSign\eSign\Client\ApiException) {
print ("\nDocuSign API error information: \n");
var_dump ($e->getResponseBody());
}
}
die();
}
# Since it isn't a POST, print the form:
?>
<html lang="en">
<body>
<form method="post">
<input type="submit" value="Send document signature request!"
style="width:21em;height:2em;background:#1f32bb;color:white;font:bold 1.5em arial;margin: 3em;"/>
</form>
</body>
</html>
(这是第一个签名者的视图。不是只有一个签名选项卡,而是两个,需要由第一个签名者签名。)
解决方案
您仅为此行中的两个签名者之一添加选项卡(签名元素):
$signer->setTabs(new DocuSign\eSign\Model\Tabs(['sign_here_tabs' => [$signHere2, $signHere]]));
您可以添加这样的一行,但可能应该考虑第二个签名者需要哪些选项卡:
$signer2->setTabs(new DocuSign\eSign\Model\Tabs(['sign_here_tabs' => [$signHere2, $signHere]]));
推荐阅读
- python - 有没有办法从图像中只提取所需的文本?
- metrics - 有效的每月活跃用户数是多少?
- javascript - 未显示动态添加到 nanogallery2 的项目
- fish - 基于正则表达式有条件地重命名文件
- javascript - 拖放动态添加的组件 - 角度 7
- c# - 通过在实体框架模型中创建虚拟导航属性 [必需] 来防止发布不足攻击
- laravel - API Postman 错误:“此路由不支持 PATCH 方法。支持的方法:GET、HEAD”
- c - 两台不同 Linux 计算机上 C 可执行文件的资源分配
- cron - 我们如何以两个不同的时间间隔运行 cron 作业,例如 - 5 分钟、5 分钟、10 分钟、5 分钟、5 分钟、10 分钟
- docker - 使用 Docker Nginx 长时间上传时出现 504