microsoftgraph / microsoftgraph/msgraph-sdk-php

How to get the values from response which list the content of a directory?

オープン
#1,464 コメント 0 件 リアクション 1 件 担当者 1 名 GitHub で見る

@SilasKenneth がすでに取り組んでいます。

2024年3月7日 から。

question
主要言語
PHP
スター
669
フォーク
150
平均マージ
15時間 21分
マージ済み PR(30日)
3

説明

Hello team
I am querying the endpoint to get the list of items inside a directory in OneDrive but I am struggling to retrieve the contents of the response received.

public static function listFilesOneDriveDir(): Models\DriveItemCollectionResponse {
        $result = GraphHelper::$appClient->drives()->byDriveId('xyz')->items()->byDriveItemId('xyz')->children()->get()->wait();
        return $result;
}

is the model DriveItemCollectionsResponse correct?
I didn't find in the documentation which Models should I use, so I was browsing the code in this repo (am I missing something here?) how to know which type of Model I am receiving?

Finally how to retrieve the attributes of each element inside the field called "values" from the response body which is an array of elements (type drive items if I am correct) I want to retrieve the attributes "name", "webUrl", "createdBy" (Object). The content of the directory are pdf or png files.

$result = GraphHelper::listFilesOneDriveDir();
foreach ($result->getValue() as $element) {
    echo $element->getSize();      // ONLY this work
    echo $element->getWebDavUrl(); // doesn't work and I dont' find methods to get "name", "createdby" or others attributes
    print("-----");
}

I think finding the methods and identifying the response type (Models) is the difficult part for me and I don't find examples about how to retrieve that data.

I would appreciate it if you could give me some instructions to familiarize myself. It is the first time that I interact with this library, however initially I followed the tutorial with Javascript and recovering the response data was easier compared to the Php version.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。