如何使用 microsoft-graph sdk php 获取 outlook 免费繁忙日程

How to get outlook free busy schedule using microsoft-graph sdk php

我正在使用 microsoft-graph api sdk 这里是 url: msgraph-sdk-php

我需要在 Outlook 日历中检查用户的约会是否有空/忙碌。

我正在尝试使用以下代码

$graph = new Graph();
$graph->setAccessToken($this->getToken($calendar));
$data = [
        'Schedules' => 'useremail@gmail.com',
        'Start' => [
            'DateTime' => '2019-06-8T09:00:00+0530',
            'TimeZone' => 'Pacific Standard Time',
        ],
        'End' => [
            'DateTime' => '2019-06-9T09:00:00+0530',
            'TimeZone' => 'Pacific Standard Time',
        ],
        'availabilityViewInterval' => '30',
    ];

    $url = "/me/calendar/getschedule";
    $response = $graph->createRequest("POST", $url)
        ->attachBody($data)
        ->setReturnType(Model\ScheduleItem::class)
        ->execute();

我收到以下错误:消息:“客户端错误:POST https://graph.microsoft.com/v1.0/me/calendar/getschedule 导致 400 Bad Request 响应:↵{ ↵ "error": { ↵ "code": "RequestBodyRead", ↵ "message": "当尝试读取空集合参数值 i (截断...)时↵

我还检查了这个微软文档的详细信息,这里是 url : outlook-get-free-busy-schedule

我没有在文档中找到 getschedule-api using php microsoft-graph sdk。我需要使用 php microsoft-graph api sdk.

请提供有关此错误的任何解决方案。

谢谢。

我们不需要通过

setReturnType

尝试使用这个:

$data = [
    'Schedules' => ['avniphadkar@gmail.com'],
    "StartTime" => (object)[
        "dateTime" => "2019-06-08T09:00:00",
        "timeZone" => "Pacific Standard Time"
    ],
    "EndTime" => (object)[
        "dateTime" => "2019-06-8T23:00:00",
        "timeZone" => "Pacific Standard Time"
    ],
    'availabilityViewInterval' => '30'
];


$url = "/me/calendar/getschedule";
$response = $graph->createRequest("POST", $url)
->attachBody($data)
->execute();

print_r($response)

;

希望这会有所帮助。