尝试通过 PHP SDK 从 Docusign 下载签名的 PDF 文件。 API 调用返回成功,文件已下载但已损坏,无法打开或显示任何内容。
代码如下:
try {
$envelopesApi = new EnvelopesApi($apiClient);
$response = $envelopesApi->getDocument('ACCOUNT_ID', $documentId, $envelopeId);
$fileContents = $response->getPathName();
// Save the downloaded document to a file or process it as needed
file_put_contents('path/filename.pdf', $fileContents);
echo 'Signed document downloaded successfully.';
} catch (ApiException $e) {
echo 'Error while downloading the signed document: ' . $e->getMessage();
}
die;
好的所以要正确下载PDF,替换:
$fileContents = $response->getPathName();
与
$fileContents = file_get_contents($response->getPathName());