我正在使用 Microsoft Graph,并希望通过我们正在编写的应用程序让用户能够将项目添加到其他用户的日历。
我正在使用以下代码,并且可以添加到我自己的日历中。
$subject = 'Subject';
$body = 'Body content';
$start = time();
$end = time() + (30 * 60);
$startStr = date('Y-m-d', $start) . 'T' . date('H:i:s', $start) . ".0000000";
$endStr = date('Y-m-d', $end) . 'T' . date('H:i:s', $end) . ".0000000";
$data = array();
$data['subject'] = $subject;
$data['body'] = array();
$data['body']['content'] = $body;
$data['start'] = array();
$data['start']['dateTime'] = $startStr;
$data['start']['timeZone'] = 'UTC';
$data['end'] = array();
$data['end']['dateTime'] = $endStr;
$data['end']['timeZone'] = 'UTC';
echo 'subject: ' . $subject . '<br>';
echo 'body: ' . $body . '<br>';
echo 'start: ' . $startStr . '<br>';
echo 'end: ' . $endStr . '<br>';
$token = $_SESSION['access_token'];
$graph = new Graph();
$graph->setAccessToken($token);
$request = $graph->createRequest("post", '/me/calendar');
$request->attachBody($data);
$response = $request->execute();
当我将 createRequest 更改为
$request = $graph->createRequest("post", '/xxxx/calendar');
其中 xxxx 是另一个用户名,我收到以下响应
400 Bad Request
我用来登录的权限是
profile openid email User.Read Calendars.ReadWrite Calendars.Read Calendars.Read.Shared Calendars.ReadWrite Calendars.ReadWrite.Shared
为了将项目发送到其他用户日历,我还需要做什么?