smartsheet api 文档提供此文档以将文件附加到行。
curl https://api.smartsheet.com/2.0/sheets/{sheetId}/rows/{rowId}/attachments
\ -H "授权:承载ll352u9jujauoqz4gstvsae05" \ -H "内容-类型:应用程序/msword" \ -H '内容-处置:附件;filename="ProgressReport.docx"' \ -H "Content-Length: FILE_SIZE" \ -X POST \ --data-binary @ProgressReport.docx
如何将其转换为对 php 中 curl 会话的适当调用?
我假设我需要创建一个标题块,例如
$headersAttachment = array(
"Authorization: Bearer " . $AccessToken,
"Content-Type: application/pdf",
'Content-Disposition: attachment; filename="mydoc.pdf"', // **is this for just the filename or the full path?**
"Content-Length: " . $FileSizeOfMyDoc
);
并像这样使用它
$curlSession = curl_init($rowsURL . '/' . $rowId . '/attachments');
curl_setopt($curlSession, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($curlSession, CURLOPT_HTTPHEADER, $headersAttachment);
curl_setopt($curlSession, CURLOPT_POSTFIELDS, $body);
curl_setopt($curlSession, CURLOPT_POST, TRUE);
$getSheetResponseData = curl_exec($curlSession);
我需要在 $body 中放入什么才能上传文件中的数据?
smartsheet api 文档说
以下示例请求显示了将文件附件添加到工作表的简单上传:
POST https://api.smartsheet.com/2.0/sheets/4509093797881732/attachments 授权:承载 ll352u9jujauoqz4gstvsae05 内容处置:附件;filename="ProgressReport.docx" 内容类型:应用程序/msword 内容长度:5463
<文件的二进制内容>
如本例所示,文件的内容包含在 POST 请求的正文中。在大多数编程语言中,这是通过从输入流中读取文件并将其写入 HTTP 请求的输出流来完成的。
这是通过从输入流中读取文件并将其写入 HTTP 请求的输出流来完成的。 <--- 我如何在 PHP 中做到这一点?
作为一个事后的想法,我怎么能用邮递员检查这个?
提前致谢。任何帮助都是极好的。