Docusign REST API:将文档下载到字符串

编程入门 行业动态 更新时间:2024-10-19 12:40:48
本文介绍了Docusign REST API:将文档下载到字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用docusign API和PHP构建应用程序。除无法弄清楚如何下载文档外,我已经完成了大部分工作。我一直在该网站和Docusign网站上进行搜索。 Docusign有一个此处的示例,它显示了如何获取PHP中的文档列表,但是下载没有PHP示例。他们在Docusign REST API文档中解释了此处的方法。但这表示响应为 PDF文件。

I am building an app using the docusign API and PHP. I have most of this working except I cannot figure out how to download the document. I have been searching on this site and on the Docusign site. Docusign has an example here, that shows how to get a list of docs in PHP, but the downloading does not have a PHP example. In the Docusign REST API docs they explain the method here. But this says the response is "PDF File".

在下面的示例代码中,我试图将内容放入文件中,但是它创建了一个空文件。如果我print_r($ data),我得到这个:

In my sample code below, I have tried to put the contents into a file, but it creates and empty file. If I print_r($data), I get this:

SplFileObject Object ( [pathName:SplFileInfo:private] => /tmp/419ULk [fileName:SplFileInfo:private] => 419ULk [openMode:SplFileObject:private] => w [delimiter:SplFileObject:private] => , [enclosure:SplFileObject:private] => " )

它确实在/ tmp中创建了文件,但我想将文档保留在字符串中,以便将其发送或保存到数据库。

It does create the file in /tmp, but I want to keep the document in a string so I send or save to DB.

这是我的控制器函数:

public function get_document($envelopeId, $cert = FALSE) { $save_dir = BASEPATH."../documents/"; if ($envelopeId) { $this->load->model('docusign_model'); $data = $this->docusign_model->get_document($envelopeId, $cert); } file_put_contents($save_dir.$envelopeId.".pdf", $data); //print_r($data); die("116"); }

这在docusign_model中:

This is in docusign_model:

public function get_document($envelopeId, $cert) { $docuSignAuth = $this->auth(); if ($docuSignAuth) { $envelopeApi = new EnvelopesApi($docuSignAuth->apiClient); $options = new GetDocumentOptions(); if($cert) { $options->setCertificate(TRUE); } else { $options->setCertificate(FALSE); } return $envelopeApi->getDocument($docuSignAuth->accountId, 1, $envelopeId, $options); } return false; }

如何获取此文档并将其保存在字符串中?

How can I get this document and keep it in a string?

任何帮助都将不胜感激!

Any and all help is greatly appreciated!

推荐答案

文件,您必须读取临时文件并将其保存到所需文件

The content comes back as a file, you have to read the temp file and save that to the desired file

使用 file_get_contents 的快速摘要 file_put_contents

$docStream = $envelopeApi->getDocument($accountId, 1, $envelopeId); file_put_contents("my_document.pdf", file_get_contents($docStream->getPathname()));

更多信息 DocuSign REST API: :EnvelopeDocuments:在以PDF文件格式获取单个文档

更多推荐

Docusign REST API:将文档下载到字符串

本文发布于:2023-11-28 10:02:16,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1641950.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字符串   文档   Docusign   REST   API

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!