Docusign - 向嵌入式签名者发送电子邮件
Docusign - Send an email to embedded signer
我正在使用嵌入式 Docusign API 来嵌入文档以供签名。我从之前的表格中将名字、姓氏和电子邮件存储在 SESSION 中。我试图将 templateRoles 中的电子邮件更改为从表单存储在 SESSION 中的电子邮件,但我要么超时,要么收到电子邮件不正确的错误消息:
"templateRoles" => array(
array( "roleName" => $templateRoleName, "email" => $email, "name" => $recipientName, "clientUserId" => $clientUserId )),
我正在使用 PHP。任何帮助表示赞赏。如果可能的话,我需要在签名完成后向嵌入式签名者发送一封包含完整表格的电子邮件。
谢谢!
编辑完整调用
session_start();
$results = array();
foreach($_SESSION['forms'] as $row){
$results[] = $row;
}
$first_name = $results[0];
$last_name = $results[1];
$email2 = $results[2];
/////////////////////////////////////////////////////////////////////////////////////////////////
// STEP 1 - Login (retrieves baseUrl and accountId)
/////////////////////////////////////////////////////////////////////////////////////////////////
$url = "https://www.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 (condition 1) webservice, status is:" . $status;
exit(-1);
}
$response = json_decode($json_response, true);
$accountId = $response["loginAccounts"][0]["accountId"];
$baseUrl = $response["loginAccounts"][0]["baseUrl"];
$headers = curl_getinfo($curl, CURLINFO_HEADER_OUT);
curl_close($curl);
/////////////////////////////////////////////////////////////////////////////////////////////////
// STEP 2 - Create an envelope with an Embedded recipient (uses the clientUserId property)
/////////////////////////////////////////////////////////////////////////////////////////////////
$data = array("accountId" => $accountId,
"emailSubject" => "Document",
"templateId" => $templateId,
"templateRoles" => array(
array( "roleName" => $templateRoleName, "email" => $email2, "name" => $recipientName, "clientUserId" => $clientUserId )),
"status" => "sent");
$data_string = json_encode($data);
$curl = curl_init($baseUrl . "/envelopes" );
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string),
"X-DocuSign-Authentication: $header" )
);
$json_response = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ( $status != 201 ) {
echo "error calling (condition 2) webservice, status is:" . $status . "<br>\nerror text is --> ";
print_r($json_response); echo "<br>\n";
exit(-1);
}
$headers = curl_getinfo($curl, CURLINFO_HEADER_OUT);
$response = json_decode($json_response, true);
$envelopeId = $response["envelopeId"];
curl_close($curl);
/////////////////////////////////////////////////////////////////////////////////////////////////
// STEP 3 - Get the Embedded Signing View
/////////////////////////////////////////////////////////////////////////////////////////////////
$data = array("returnUrl" => "http://www.theURL.com/docusign/thank-you",
"authenticationMethod" => "None", "email" => $email,
"userName" => $recipientName, "clientUserId" => $clientUserId
);
$data_string = json_encode($data);
$curl = curl_init($baseUrl . "/envelopes/$envelopeId/views/recipient" );
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string),
"X-DocuSign-Authentication: $header" )
);
$json_response = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ( $status != 201 ) {
echo "error calling webservice (condition 3), status is:" . $status . "\nerror text is --> ";
print_r($json_response); echo "\n";
exit(-1);
}
$headers = curl_getinfo($curl, CURLINFO_HEADER_OUT);
$response = json_decode($json_response, true);
$url = $response["url"];
if ( $detect->isMobile() ) {
echo "<p style='color:white;'>Click to Sign the Consent Form on your mobile device:</p>";
echo "<a href='$url' style='width:100%; padding: 10px 20px; border: 3px solid white; color: white;'>Sign eConsent Form</a>";
} else {
echo "<iframe src='$url' style='width:100%; height:100%; min-height: 800px;overflow:scroll;'></iframe>";
}
授权在另一个文件中,包含 templateID、电子邮件和密码、clientID 等
当您以管理员身份登录时,您需要在您的帐户上启用一项设置。
首选项 > 功能 > 为(未禁止的)嵌入式签名者使用信封完整电子邮件
我正在使用嵌入式 Docusign API 来嵌入文档以供签名。我从之前的表格中将名字、姓氏和电子邮件存储在 SESSION 中。我试图将 templateRoles 中的电子邮件更改为从表单存储在 SESSION 中的电子邮件,但我要么超时,要么收到电子邮件不正确的错误消息:
"templateRoles" => array(
array( "roleName" => $templateRoleName, "email" => $email, "name" => $recipientName, "clientUserId" => $clientUserId )),
我正在使用 PHP。任何帮助表示赞赏。如果可能的话,我需要在签名完成后向嵌入式签名者发送一封包含完整表格的电子邮件。
谢谢!
编辑完整调用
session_start();
$results = array();
foreach($_SESSION['forms'] as $row){
$results[] = $row;
}
$first_name = $results[0];
$last_name = $results[1];
$email2 = $results[2];
/////////////////////////////////////////////////////////////////////////////////////////////////
// STEP 1 - Login (retrieves baseUrl and accountId)
/////////////////////////////////////////////////////////////////////////////////////////////////
$url = "https://www.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 (condition 1) webservice, status is:" . $status;
exit(-1);
}
$response = json_decode($json_response, true);
$accountId = $response["loginAccounts"][0]["accountId"];
$baseUrl = $response["loginAccounts"][0]["baseUrl"];
$headers = curl_getinfo($curl, CURLINFO_HEADER_OUT);
curl_close($curl);
/////////////////////////////////////////////////////////////////////////////////////////////////
// STEP 2 - Create an envelope with an Embedded recipient (uses the clientUserId property)
/////////////////////////////////////////////////////////////////////////////////////////////////
$data = array("accountId" => $accountId,
"emailSubject" => "Document",
"templateId" => $templateId,
"templateRoles" => array(
array( "roleName" => $templateRoleName, "email" => $email2, "name" => $recipientName, "clientUserId" => $clientUserId )),
"status" => "sent");
$data_string = json_encode($data);
$curl = curl_init($baseUrl . "/envelopes" );
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string),
"X-DocuSign-Authentication: $header" )
);
$json_response = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ( $status != 201 ) {
echo "error calling (condition 2) webservice, status is:" . $status . "<br>\nerror text is --> ";
print_r($json_response); echo "<br>\n";
exit(-1);
}
$headers = curl_getinfo($curl, CURLINFO_HEADER_OUT);
$response = json_decode($json_response, true);
$envelopeId = $response["envelopeId"];
curl_close($curl);
/////////////////////////////////////////////////////////////////////////////////////////////////
// STEP 3 - Get the Embedded Signing View
/////////////////////////////////////////////////////////////////////////////////////////////////
$data = array("returnUrl" => "http://www.theURL.com/docusign/thank-you",
"authenticationMethod" => "None", "email" => $email,
"userName" => $recipientName, "clientUserId" => $clientUserId
);
$data_string = json_encode($data);
$curl = curl_init($baseUrl . "/envelopes/$envelopeId/views/recipient" );
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string),
"X-DocuSign-Authentication: $header" )
);
$json_response = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ( $status != 201 ) {
echo "error calling webservice (condition 3), status is:" . $status . "\nerror text is --> ";
print_r($json_response); echo "\n";
exit(-1);
}
$headers = curl_getinfo($curl, CURLINFO_HEADER_OUT);
$response = json_decode($json_response, true);
$url = $response["url"];
if ( $detect->isMobile() ) {
echo "<p style='color:white;'>Click to Sign the Consent Form on your mobile device:</p>";
echo "<a href='$url' style='width:100%; padding: 10px 20px; border: 3px solid white; color: white;'>Sign eConsent Form</a>";
} else {
echo "<iframe src='$url' style='width:100%; height:100%; min-height: 800px;overflow:scroll;'></iframe>";
}
授权在另一个文件中,包含 templateID、电子邮件和密码、clientID 等
当您以管理员身份登录时,您需要在您的帐户上启用一项设置。
首选项 > 功能 > 为(未禁止的)嵌入式签名者使用信封完整电子邮件