docusignapi - 完成文档签名后无法获取 webhook 数据
问题描述
我已使用本地实例中的此代码将要签名的文档发送给签名者
print_r(send_document_for_signing());
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 = 'myAccessTokes';
# 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 = '';
# Recipient Information:
$signerName = '';
$signerEmail = '';
# The document you wish to send. Path is relative to the root directory of this repo.
$fileNamePath = 'test/Docs/SignTest1.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);
$document = new DocuSign\eSign\Model\Document([ # create the DocuSign document object
'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
]);
$envelope_events = [
(new \DocuSign\eSign\Model\EnvelopeEvent())->setEnvelopeEventStatusCode("sent"),
];
$recipient_events = [
(new \DocuSign\eSign\Model\RecipientEvent())->setRecipientEventStatusCode("Completed"),
];
$event_notification = new \DocuSign\eSign\Model\EventNotification();
$event_notification->setUrl('mysite/docusign_test/test.php');
$event_notification->setLoggingEnabled("true");
$event_notification->setRequireAcknowledgment("true");
$event_notification->setUseSoapInterface("false");
$event_notification->setIncludeCertificateWithSoap("false");
$event_notification->setSignMessageWithX509Cert("false");
$event_notification->setIncludeDocuments("true");
$event_notification->setIncludeEnvelopeVoidReason("true");
$event_notification->setIncludeTimeZone("true");
$event_notification->setIncludeSenderAccountAsCustomField("true");
$event_notification->setIncludeDocumentFields("true");
$event_notification->setIncludeCertificateOfCompletion("true");
$event_notification->setEnvelopeEvents($envelope_events);
$event_notification->setRecipientEvents($recipient_events);
# The signer object
$signer = new DocuSign\eSign\Model\Signer([
'email' => $signerEmail, 'name' => $signerName, 'recipient_id' => "1", 'routing_order' => "1"
]);
# 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
'recipients' => new DocuSign\eSign\Model\Recipients(['signers' => [$signer]]), # The Recipients object wants arrays for each recipient type
'status' => "sent", # requests that the envelope be created and sent.
]);
$envelopeDefinition->setEventNotification($event_notification);
#
# 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;
它已成功将电子邮件发送给签名者,完成文档后,我收到了已完成的电子邮件。
因为我已经分配了一个url
我想收到我对已完成文档的回复的内容,因为我想在那里进行一些处理。但它没有返回响应,我无法获取完整的文档响应。
编辑:我还在服务器上制作了测试文件,我想在其中获得响应并阅读它。
文件中的代码test.php
:
<?php
$data = file_get_contents('php://input');
file_put_contents('data.txt', $data);
?>
解决方案
您用于 webhook 的 url 是什么?有一种方法可以检查连接日志以查看是否有人尝试调用您的代码以及它是否工作正常。这应该允许您更多地隔离问题(您还可以确认您的代码是通过使用调试技术调用的)
有关连接日志的信息,请参见此处 - https://support.docusign.com/guides/ndse-admin-guide-connect
推荐阅读
- python - 序列的计数(不重复)
- sql - SQL 查询以查找与表中其他元素相关的最常见元素
- python - 由 groupby 产生的 pandas 数据框中的列名
- javascript - Socket.io 不能在没有 express 的情况下使用外部访问
- jpa - 将单个实体字段映射到 spring data jpa 和 postgres sql 中的多个 dB 列
- php - 在虚拟主机中调用未定义的函数 mysql_connect()
- php - Phabricator - 我自己的应用程序、路由器和 404 错误
- postgresql - 如何在postgresql中将字符变量如2000转换为2,000.00格式
- android - 显示默认空场景的 HelloAR 示例场景
- c# - 半书面 Lambda 查询的分组和排序