我正在尝试使用docusign嵌入式签名获得2位用户签名。我正在使用Docusign / github提供的示例代码。我想第二个用户,看到第一个用户签署了文档,所以,根据这里的一些解释,我尝试获取信封ID,当第一个签名者签署文档,但我得到一个错误。似乎第二个收件人有问题。有人会帮忙吗?
$username_docusign=$config['username_docusign'];
$password_docusign=$config['password_docusign'];
$integrator_key_docusign=$config['integrator_key_docusign'];
$host_docusign=$config['host_docusign'];
// create a new DocuSign configuration and assign host and header(s)
$config = new DocuSign\eSign\Configuration();
$config->setSSLVerification(false);
$config->setHost($host_docusign);
$config->addDefaultHeader("X-DocuSign-Authentication", "{\"Username\":\"" . $username_docusign . "\",\"Password\":\"" . $password_docusign . "\",\"IntegratorKey\":\"" . $integrator_key_docusign . "\"}");
/////////////////////////////////////////////////////////////////////////
// STEP 1: Login() API
/////////////////////////////////////////////////////////////////////////
// instantiate a new docusign api client
$apiClient = new DocuSign\eSign\ApiClient($config);
// we will first make the Login() call which exists in the AuthenticationApi...
$authenticationApi = new DocuSign\eSign\Api\AuthenticationApi($apiClient);
// optional login parameters
$options = new \DocuSign\eSign\Api\AuthenticationApi\LoginOptions();
// call the login() API
$loginInformation = $authenticationApi->login($options);
// parse the login results
if(isset($loginInformation) && count($loginInformation) > 0)
{
// note: defaulting to first account found, user might be a
// member of multiple accounts
$loginAccount = $loginInformation->getLoginAccounts()[0];
if(isset($loginInformation))
{
$accountId = $loginAccount->getAccountId();
if(!empty($accountId))
{
echo "Account ID = $accountId\n";
}
}
}
/////////////////////////////////////////////////////////////////////////
// STEP 2: Create & Send Envelope with Embedded Recipient
/////////////////////////////////////////////////////////////////////////
// set recipient information
$recipientName = "user1";
$recipientEmail = "email1";
// configure the document we want signed
$recipientName2 = "user2";
$recipientEmail2 = "email2";
$documentFileName = "hhhh.pdf";
$documentName = "hhhh.pdf";
// instantiate a new envelopeApi object
$envelopeApi = new DocuSign\eSign\Api\EnvelopesApi($apiClient);
// Add a document to the envelope
$document = new DocuSign\eSign\Model\Document();
$document->setDocumentBase64(base64_encode(file_get_contents($document)));
$document->setName($documentName);
$document->setDocumentId("1");
// Create a |SignHere| tab somewhere on the document for the recipient to sign
$signHere = new \DocuSign\eSign\Model\SignHere();
$signHere->setAnchorString("Sign here user1");//here my text in html
$signHere->setAnchorXOffset("3");
$signHere->setAnchorYOffset("0");
$signHere->setAnchorUnits("inches");
$signHere->setPageNumber("1");
$signHere->setRecipientId("1");
// add the signature tab to the envelope's list of tabs
$tabs = new DocuSign\eSign\Model\Tabs();
$tabs->setSignHereTabs(array($signHere));
// add a signer to the envelope
$signer = new \DocuSign\eSign\Model\Signer();
$signer->setEmail($recipientEmail);
$signer->setName($recipientName);
$signer->setRecipientId("1");
$signer->setTabs($tabs);
$signer->setClientUserId('12345');
$signHere2 = new \DocuSign\eSign\Model\SignHere();
$signHere2->setAnchorString("Sign here user2");//here my text in html
$signHere2->setAnchorXOffset("3");
$signHere2->setAnchorYOffset("0");
$signHere2->setAnchorUnits("inches");
$signHere2->setPageNumber("1");
$signHere2->setRecipientId("2");
// add the signature tab to the envelope's list of tabs
$tabs2 = new DocuSign\eSign\Model\Tabs();
$tabs2->setSignHereTabs(array($signHere2));
// add a signer to the envelope
$signer2 = new \DocuSign\eSign\Model\Signer();
$signer2->setEmail($recipientEmail2);
$signer2->setName($recipientName2);
$signer2->setRecipientId("2");
$signer2->setTabs($tabs2);
$signer2->setClientUserId('123456');
// must set this to embed the recipient!
// Add a recipient to sign the document
$recipients = new DocuSign\eSign\Model\Recipients();
$recipients->setSigners(array($signer),array($signer2) );
$envelop_definition = new DocuSign\eSign\Model\EnvelopeDefinition();
$envelop_definition->setEmailSubject("oggetto mail");
// set envelope status to "sent" to immediately send the signature request
$envelop_definition->setStatus("sent");
$envelop_definition->setRecipients($recipients);
$envelop_definition->setDocuments(array($document));
// create and send the envelope! (aka signature request)
$envelop_summary = $envelopeApi->createEnvelope($accountId, $envelop_definition, null);
/////////////////////////////////////////////////////////////////////////
// STEP 3: Request Recipient View (aka signing URL)
/////////////////////////////////////////////////////////////////////////
// instantiate a RecipientViewRequest object
$recipient_view_request = new \DocuSign\eSign\Model\RecipientViewRequest();
// set where the recipient is re-directed once they are done signing
$recipient_view_request->setReturnUrl("http://www.elevationworld.com/adr/embedded.php?iddocumento_firmato=".$_GET['iddocumento']."&idutente_firmato=".$_SESSION['email']."&enevelope=".$envelop_summary->getEnvelopeId());
// configure the embedded signer
if ($_GET['enevelope']=="") {
$recipient_view_request->setUserName($recipientName);
$recipient_view_request->setEmail($recipientEmail);
// must reference the same clientUserId that was set for the recipient when they
// were added to the envelope in step 2
$recipient_view_request->setClientUserId('12345');
// used to indicate on the certificate of completion how the user authenticated
$recipient_view_request->setAuthenticationMethod("email");
// generate the recipient view! (aka embedded signing URL)
$signingView = $envelopeApi->createRecipientView($accountId, $envelop_summary->getEnvelopeId(), $recipient_view_request);
$signurl= $signingView->getUrl();
} else {
$recipient_view_request->setUserName($recipientName2);
$recipient_view_request->setEmail($recipientEmail2);
// must reference the same clientUserId that was set for the recipient when they
// were added to the envelope in step 2
$recipient_view_request->setClientUserId('12345');
// used to indicate on the certificate of completion how the user authenticated
$recipient_view_request->setAuthenticationMethod("email");
// generate the recipient view! (aka embedded signing URL)
$signingView = $envelopeApi->createRecipientView($accountId, $_GET['enevelope'], $recipient_view_request);
$signurl= $signingView->getUrl();
}
header('Location: '.$signurl);
答案 0 :(得分:1)
在为签名者2检索recipientURL时是否收到错误?我可以看到你在STEP2中创建了signer2,clientuserId为123456,但在STEP3中,你试图用clientUserId和12345获取url。
在第2步中,您有
$signer2->setClientUserId('123456');
在STEP3中,您正在传递
//已添加到第2步中的信封
$recipient_view_request->setClientUserId('12345');
如果您为signer2设置了正确的clientUserId,那么我认为问题将为您解决。