我已使用本地实例中的此代码将要签名的文档发送给签名人
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);
?>
答案 0 :(得分:1)
您用于Webhook的网址是什么? 有一种方法可以检查连接日志,以查看是否尝试调用您的代码,以及它是否正常运行。这应该可以使您进一步隔离问题(您还可以通过使用调试技术来确认您的代码已被调用)
请参阅此处-https://support.docusign.com/guides/ndse-admin-guide-connect,以获取有关连接日志的信息
答案 1 :(得分:1)
EventNotifications的URL必须使用HTTPS保护。如果您使用的是http://{url}/
,它将失败。