首页 > 解决方案 > 如何使用 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);

标签: phponedriveazure-ad-graph-api

解决方案


Google Chrome 有一个免费的扩展程序,用于文档、表格和幻灯片的 Office 编辑

此扩展允许您在 Drive 中打开 MS .docx 文件并对其进行编辑,而无需先进行转换。

如果您想使用 Graph API 并以编程方式从 Web 应用程序打开,您可以查看此线程,其中介绍了如何执行此操作。如何使用桌面 Word 以编程方式打开位于 OneDrive 中的文件?


推荐阅读