2017-01-09 71 views
0

我正在使用php Api for docusign。從here得到它。我想要的是獲得簽署的DOC的網址。有沒有可能得到這個。 ?我正在使用下面的代碼。如何獲取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直接有/accounts/{{accid}}/envelopes/{{envid}}/documents/combined端點,爲您提供一個PDF信封的所有文件,但我無法找到類似的進SDK(無論是在Java或PHP)任何東西。

希望它有幫助!

+0

沒有得到文檔PDF。任何猜測我怎麼能做到這一點? – MKD

+0

@Ergin答案補充了我的答案。您需要獲取字節並將其轉換爲PDF。 – jfneis

0

就像@jfneis提到的那樣,您需要使用getDocument() API來檢索信封的實際簽名文檔字節。在你做之前,你要求listDocuments()請求獲得下載每個文檔的實際文檔端點。

請注意,每個下載信封文檔的終端都將包含documentId作爲URL的一部分。所以,如果你有信封「AAA」有兩個文件(編號1001和1002),例如,下載他們,你會怎麼做:

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