php - 如何使用 php 在微软企业帐户中以可编辑格式打开文档?
问题描述
如何以可编辑格式打开文档(.docx)?当我上传文档文件时,它会在微软企业帐户的驱动器中成功查看吗?
$uri ='https://graph.microsoft.com/v1.0/me/drive/root:/roshan.docx:/content';
$headers = array( 'Content-Type: application/text', "Cache-Control: no- cache", "Pragma: no-cache", "Authorization: bearer ".$pppp );
$output = "";
$pointer = fopen($filpath, 'r+');
$stat = fstat($pointer);
$pointersize = $stat['size'];
$ch = curl_init($uri);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_PUT, true);
curl_setopt($ch, CURLOPT_INFILE, $pointer);
curl_setopt($ch, CURLOPT_INFILESIZE, (int) $pointersize);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_FRESH_CONNECT, TRUE);
$output = curl_exec($ch);
$output = json_decode($output, true);
解决方案
Google Chrome 有一个免费的扩展程序,用于文档、表格和幻灯片的 Office 编辑。
此扩展允许您在 Drive 中打开 MS .docx 文件并对其进行编辑,而无需先进行转换。
如果您想使用 Graph API 并以编程方式从 Web 应用程序打开,您可以查看此线程,其中介绍了如何执行此操作。如何使用桌面 Word 以编程方式打开位于 OneDrive 中的文件?
推荐阅读
- c# - 从数据库中检索下拉值并将检索到的值显示为与其他下拉列表项一起选择的值
- html - right align li in flex ul
- java - Kotlin 协程 vs CompletableFuture
- c++ - can't find a way to make garanteed return value optimization work
- javafx - How to make scene local JavaFX
- powershell - Move Files Containing X in their Names to Folder X
- java - Java:导出 Microsoft Access 数据库中 OLE 列中包含的与设备无关的位图流
- admob - 如果我只使用 admob,我需要对数据收集和分析工具进行哪些声明?
- browser-sync - 无法使用浏览器同步启动 chrome
- typescript - 过滤掉映射类型的索引