通过电子邮件发送带有PHP标记字段的DocuSign PDF



我是DocuSign的初学者。我正在寻找一个PHP中的API,它可以用来通过电子邮件发送链接,打开DocuSign中带有标记字段的PDF。我在Stackoverflow中查找了许多代码并进行了尝试,但它没有满足我的需求。它打开PDF时没有显示标记的字段,每次都必须拖动字段。我想要类似于powerform的东西,其中PDF中的字段被标记并可以通过电子邮件发送。我已经坚持了很多天,但没有找到解决方案。这在PHP中可能吗?请帮助

下面是我试过的其中一个,但它没有标记字段https://github.com/docusign/code-examples-php

<?php
/////////////////////////////////////////////////////////////////////////////////////////////////
// STEP 1 - Login (to retrieve 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 "naccountId = " . $accountId . "nbaseUrl = " . $baseUrl . "n";
/////////////////////////////////////////////////////////////////////////////////////////////////
// STEP 2 - Create an envelope with one recipient, one tab, one document and send!
/////////////////////////////////////////////////////////////////////////////////////////////////
$data = "{
"emailBlurb":"
Hi,
Thanks",
"emailSubject":"Registering",
"documents":[
{
"documentId":"1",
"name":"".$document_name.""
}
],
"recipients":{
"signers":[
{
"email":"$recipient_email",
"name":"$name",
"recipientId":"1",
"tabs":{
"signHereTabs":[
{
"anchorString":"Signature:",
"anchorXOffset":"0",
"anchorYOffset":"0",
"documentId":"1",
"pageNumber":"1"
}
]
}
}
]
},
"status":"sent"
}";  
$file_contents = file_get_contents($document_name);
$requestBody = "rn"
."rn"
."--myboundaryrn"
."Content-Type: application/jsonrn"
."Content-Disposition: form-datarn"
."rn"
."$datarn"
."--myboundaryrn"
."Content-Type:application/pdfrn"
."Content-Disposition: file; filename="REGISTRATION_FORM.pdf"; documentid=1 rn"
."rn"
."$file_contentsrn"
."--myboundary--rn"
."rn";
// *** append "/envelopes" to baseUrl and as signature request endpoint
$curl = curl_init($baseUrl . "/envelopes" );
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $requestBody);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Content-Type: multipart/form-data;boundary=myboundary',
'Content-Length: ' . strlen($requestBody),
"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"];
//--- display results
echo "Document is sent! Envelope ID = " . $envelopeId . "nn"; 
?>

签名者被要求在签名仪式期间放置字段的原因是信封中没有分配给签名者的字段。

我的猜测是找不到锚文本Signature:。尝试只查找字符串Signature

但更重要的是,我不知道你在哪里找到了示例代码,但这不是一条路。

相反,使用Quickstart过程来获得一个使用SDK的工作PHP程序,然后对其进行修改。您的代码正在尝试更困难的事情,用字符串创建JSON并使用CURL。

最新更新