duanfang5849 2018-10-12 09:05
浏览 153

如何从docusign API获取文档?

I want to know how can I get a signed document from docusign API? I can already do a signture request via email (it works fine!). But I want that when a document is completed to show it on url click.

The documentation is not very clear...

Here a part of my php code:

try
    {
        //*** STEP 1 - Login API: get first Account ID and baseURL
        //..............//

        if(isset($loginInformation) && count($loginInformation) > 0)
        {
            $loginAccount = $loginInformation->getLoginAccounts()[0];
            $host = $loginAccount->getBaseUrl();
            $host = explode("/v2",$host);
            $host = $host[0];

            // UPDATE configuration object
            $config->setHost($host);

            // instantiate a NEW docusign api client (that has the correct baseUrl/host)
            $apiClient = new DocuSign\eSign\ApiClient($config);

            if(isset($loginInformation))
            {
                $accountId = $loginAccount->getAccountId();
                if(!empty($accountId))
                {
                    $envelopeApi = new DocuSign\eSign\Api\EnvelopesApi($apiClient);

                    $docsList = $envelopeApi->listDocuments($accountId, $envelopeId);
                    $documents = $docsList->getEnvelopeDocuments();

                    foreach($documents as $index => $document)
                    {
                        $url = $config->getHost().'/v2/accounts/'.$accountId.'/'.$document->getUri();
//------>Here i get the url but i cant read this file???

                    }
                }
            }
        }
    }

This url doesn't response, what am I doing wrong?

  • 写回答

1条回答 默认 最新

  • dppx9253 2019-08-25 21:58
    关注

    the getUri() method on the document simply returns back the Uri that correspond to the API call to get this document. That's not how you download the document. You get it using getDocumentBase64() which will return a long string of the doc in base64. then if you want to convert this back to bits you can use the base64_decode method. Then you can sent it back from server to client as a pdf document to be downloaded.

    评论

报告相同问题?

悬赏问题

  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程