问题描述
我正在使用DocuSign PHP Rest API。我复制了一个快速入门示例,但是,它引发了HTTP 500错误。我也是这个API的新手,所以对可能导致此错误的任何帮助将不胜感激。浏览器控制台中什么也没有显示,我似乎找不到代码中是否存在语法错误。
我会认为找不到适当的API?
这是sign-request.PHP
<?PHP
require_once("vendors/docusign/autoload.PHP");
function send_document_for_signing(){
$accesstoken = '***hidden***';
$accountId = '***hidden***';
$signerName = 'John Doe';
$signerEmail = 'John.Doe@example.com';
$fileNamePath = 'demo/demo_orderform.pdf';
$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' => $signerEmail,'name' => $signerName,'recipient_id' => "1",'routing_order' => "1"
]);
# 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'
]);
# 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' => [$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]]),'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: <?PHP $results['status'] ?>,Envelope ID: <?PHP $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>
出于安全原因,我已经隐藏了OAuth令牌,帐户ID和真实的姓名和电子邮件。
任何帮助都会很方便。
非常感谢, 内森
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)