如何获取根文件夹驱动器上的文件 PHP MS Graph SDK

问题描述 投票:0回答:1

这可能是一个简单的问题,但文档不清楚或有错误。 当你想从已知文件夹中获取文件时,方法如下:

GET /drives/{drive-id}/items/{item-id}/children

<?php
use Microsoft\Graph\GraphServiceClient;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$result = $graphServiceClient->drives()->byDriveId('drive-id')->items()->byDriveItemId('driveItem-id')->children()->get()->wait();

您有一个 DriveId 和 DriveItemdId,然后您询问文件... 但如果您想要驱动器根文件夹中的文件,则网址如下:

获取/我/驱动器/root/children

但是,你能告诉我 PHP SDK 的情况如何吗?因为文档显示了其他内容,如果您知道文件夹 ID 如何进行。 这是文档的网址: https://learn.microsoft.com/en-us/graph/api/driveitem-list-children?view=graph-rest-1.0&tabs=php

谢谢你

php microsoft-graph-sdks
1个回答
0
投票

恐怕在这种情况下你需要调用 Graph API 两次。

一次获取您的驱动器的 ID,然后将子项放入驱动器的根目录中。

$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);

$drive = $graphServiceClient->me()->drive()->get()->wait();

$result = $graphServiceClient->drives()->byDriveId($drive->getId())->items()->byDriveItemId('root')->children()->get()->wait();

我认为SDK不会生成类似的客户端代码

$result = $graphServiceClient->me()->drive()->items()->byDriveItemId('root')->children()->get()->wait();
© www.soinside.com 2019 - 2024. All rights reserved.