Электронная почта DocuSign PDF с отмеченными полями на PHP

#docusignapi

#docusignapi

Вопрос:

Я новичок в DocuSign. Я ищу API на PHP, который можно использовать для отправки по электронной почте ссылки, которая открывает PDF-файл в DocuSign с отмеченными полями. Я искал много кодов в 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"; 

?>
  

Ответ №1:

Причина, по которой подписавшего просят разместить поля во время церемонии подписания, заключается в том, что в конверте, назначенном подписавшему, нет полей.

Я предполагаю, что текст привязки Signature: не найден. Попробуйте найти только строку Signature

Но что еще более важно, я не знаю, где вы нашли пример кода, но это не тот путь.

Вместо этого используйте процесс быстрого запуска, чтобы получить рабочую PHP-программу, использующую SDK, а затем измените ее. Ваш код пытается сделать что-то гораздо более сложное, создавая JSON в строках и используя CURL.

Комментарии:

1. Спасибо. Помог быстрый запуск