Docusign - 发送电子邮件给嵌入式签名者

时间:2015-03-26 17:25:05

标签: php docusignapi

我使用嵌入式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等的文件中。

1 个答案:

答案 0 :(得分:1)

当您以管理员身份登录时,您需要在帐户中启用设置。

偏好设置&gt;特征&gt;使用Envelope完成电子邮件(非抑制)嵌入式签名者

enter image description here