2017-01-09 1 views
0

docusign 용 PHP Api를 사용하고 있습니다. here에서 가져 왔습니다. 내가 원하는 것은 서명 한 DOC의 URL을 얻는 것입니다. 그것을 얻을 수 있습니까? ? 다음 코드를 사용하고 있습니다.어떻게 pdf url을 얻을 수 있습니까? docusign Php Api

$username = $option['docu_username']; 
    $password =$option['docu_pass']; 
    $integrator_key = $option['docu_integrator_key']; 
    $host = $option['docu_host']; 
    // create a new DocuSign configuration and assign host and header(s) 
    $config = new DocuSign\eSign\Configuration(); 
    $config->setHost($host); 
    $config->addDefaultHeader("X-DocuSign-Authentication", "{\"Username\":\"" . $username . "\",\"Password\":\"" . $password . "\",\"IntegratorKey\":\"" . $integrator_key . "\"}"); 
    ///////////////////////////////////////////////////////////////////////// 
    // 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)) 
    { 
     return false; 
    } 
    ///////////////////////////////////////////////////////////////////////// 
    // STEP 2: Create & Send Envelope (aka Signature Request) 
    ///////////////////////////////////////////////////////////////////////// 
    // set recipient information 

    // 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($documentFileName))); 
    $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->setXPosition("20"); 
    $signHere->setYPosition("20"); 
    $signHere->setDocumentId("1"); 
    $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->setClientUserId('12345'); 
    $signer->setTabs($tabs); 
    // Add a recipient to sign the document 
    $recipients = new DocuSign\eSign\Model\Recipients(); 
    $recipients->setSigners(array($signer)); 
    $envelop_definition = new DocuSign\eSign\Model\EnvelopeDefinition(); 
    $envelop_definition->setEmailSubject("Please sign this doc"); 
    // 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); 
$viewrequest = new DocuSign\eSign\Model\RecipientViewRequest(); 
     $viewrequest->setUserName($recipientName); 
     $viewrequest->setEmail($recipientEmail); 
     $viewrequest->setRecipientId(1); 
     $viewrequest->setClientUserId('12345'); 
     $viewrequest->setAuthenticationMethod('email'); 
     $viewrequest->setReturnUrl($ReturnUrl); 
     $envelopview=$envelopeApi->createRecipientView($accountId,$document->envelopeId,$viewrequest); 
     $redirecturl=$envelopview->getUrl(); 

답변

1

예, 그렇습니다. 봉투의 문서를 열거하고 가져올 수도 있습니다.

listDocumentsgetDocument 방법을 살펴보십시오. PHP로 프로그래밍하지 않기 때문에 예제를 제공 할 수는 없지만 단지 GitHub PHP SDK repo과 해당 코드를 사용할 수 있는지 확인하십시오.

덧붙여 말하자면, REST API를 직접 사용하면 봉투의 모든 문서를 단일 PDF로 제공하는 엔드 포인트가 /accounts/{{accid}}/envelopes/{{envid}}/documents/combined이지만 SDK (Java 또는 PHP 제외)와 비슷한 것을 찾을 수 없습니다.

희망이 있습니다.

+0

doc pdf가 없습니다. 어떤 추측을 할 수 있을까요? – MKD

+0

@Ergin 응답이 내 대답을 보완합니다. 바이트를 가져와 PDF로 변환해야합니다. – jfneis

0

@jfneis와 마찬가지로, getDocument() API를 사용하여 봉투의 실제 서명 된 문서 바이트를 검색해야합니다. 하지만이를 수행하기 전에 listDocuments() 요청을 작성하여 각 문서를 다운로드하기위한 실제 문서 끝점을 가져와야합니다.

봉투 도큐멘트를 다운로드하는 각 끝점에는 documentId이 URL의 일부로 포함됩니다. 예를 들어 두 개의 문서 (ID 1001과 1002)가있는 봉투 "AAA"가있는 경우 다운로드하려면 다음을 수행하십시오.

GET v2/accounts/12345/envelopes/AAA/documents/1001 
GET v2/accounts/12345/envelopes/AAA/documents/1002