php - 如何在 PHP 中访问 SharePoint 上的共享文件?
问题描述
我对 SharePoint 一点也不熟悉,我正在尝试构建一个 php 脚本来浏览和访问在这样的文件夹中与我们共享的文件:https ://blabla.sharepoint.com/:b:/r/sites/ SubSiteName/Shared%20Documents/OurCompanyName/Invoice
我找到了这些库:https://github.com/vgrem/phpSPO和https://github.com/thybag/PHP-SharePoint-Lists-API,但我找不到访问文件的好方法. 我还在这里找到了谈到 php 和 SharePoint 的帖子,但似乎没有一个符合我的需要。
我已经用 phpSPO 尝试过这段代码,但它在 executeQuery() 失败:
$authCtx = new AuthenticationContext('https://blabla.sharepoint.com');
$authCtx->acquireTokenForUser('our@email','password');
$ctx = new ClientContext('https://blabla.sharepoint.com',$authCtx);
$fileUrl = '/sites/SubSiteName/Shared Documents/OurCompanyName/Invoice/INV_123.PDF';
$file = $ctx->getWeb()->getFileByServerRelativeUrl($fileUrl);
$ctx->load($file);
$ctx->executeQuery();
print "File name: '{$file->getProperty("Name")}'\r\n";
解决方案
SharePoint 具有可用于获取特定文件的 REST API
url: http://site url/_api/web/GetFolderByServerRelativeUrl('/Folder Name')/Files('file name')/$value
method: GET
推荐阅读
- uiveri5 - 运行 uiveri5 的示例测试用例显示错误“参考错误:未定义描述”
- rust - 如何从 actix_web::HttpRequest 获取(二进制)有效负载
- macos - docker-compose 中的平台条件
- javascript - 使用 Google Analytics Embed API 时没有显示任何内容
- sql - 有没有更好的方法通过加入 Redshift 来避免数据倾斜?
- ios - 带有 LongPressGestureRecognizer 的 Mapkit 间歇性工作
- php - 找到单词并用 str_replace 突出显示
- java - 仅当 XML/HTML 标记在特定标记之外时才附加它。JAVA/JSOUP
- c - 如何在C中使用open mp同时执行两个不同的功能
- electron - 电子:如何为 Darwin/OS X 设置文本