How to create an event in a "Group Calendar" using the MS Graph APIs? This is only possible using delegated permission from a Work or School Account. Would you please share the code to achieve that (using the PHP - new Graph())? Is it possible to do it completely silently, or login or consent pop-ups are involved?
HideAndSeek says he did it in the post: Microsoft Graph API: Group Calendar Events created by API are not sent to users Calendar but he does not share the code or explained how he did it.
Thanks
To use APIs that only support delegated permissions, authentication + user consent is required. Below is a code sample assuming the access token variable is acquired with delegated permissions. I am using MS Graph PHP SDK
$accessToken = 'eyJ0...';
$graph = new Graph();
$graph->setAccessToken($accessToken);
$attendees = [];
array_push($attendees, [
'emailAddress' => [
'address' => '[email protected]',
'name' => 'Name'
],
'type' => 'required'
]);
$newEvent = [
'subject' => 'Sample Event Subject',
'attendees' => $attendees,
'start' => [
'dateTime' => '2021-05-12T22:00:00',
'timeZone' => 'Pacific Standard Time'
],
'end' => [
'dateTime' => '2021-05-12T23:00:00',
'timeZone' => 'Pacific Standard Time'
],
'body' => [
"contentType" => "HTML",
"content" => "Chat about new hire"
]
];
$response = $graph->createRequest('POST', '/groups/group-id/calendar/events')
->attachBody($newEvent)
->setReturnType(Model\Event::class)
->execute();
echo "Created event - {$response->getSubject()}.";
Here is a complete example that will help you get started. The Guide is here
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Find the answer in similar questions on our website.
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.
PHP (from the English Hypertext Preprocessor - hypertext preprocessor) is a scripting programming language for developing web applications. Supported by most hosting providers, it is one of the most popular tools for creating dynamic websites.
The PHP scripting language has gained wide popularity due to its processing speed, simplicity, cross-platform, functionality and distribution of source codes under its own license.
https://www.php.net/
HTML (English "hyper text markup language" - hypertext markup language) is a special markup language that is used to create sites on the Internet.
Browsers understand html perfectly and can interpret it in an understandable way. In general, any page on the site is html-code, which the browser translates into a user-friendly form. By the way, the code of any page is available to everyone.
https://www.w3.org/html/
Welcome to the Q&A site for web developers. Here you can ask a question about the problem you are facing and get answers from other experts. We have created a user-friendly interface so that you can quickly and free of charge ask a question about a web programming problem. We also invite other experts to join our community and help other members who ask questions. In addition, you can use our search for questions with a solution.
Ask about the real problem you are facing. Describe in detail what you are doing and what you want to achieve.
Our goal is to create a strong community in which everyone will support each other. If you find a question and know the answer to it, help others with your knowledge.