Office 365 intergragtion with scriptcase and not google

More of a discussion for office 365 default integration instead of google.

Anyone else work with office 365 integration instead of google. It seams to me in this day and age office 365 web apps should be able to be integrated into scriptcase just like they have done with google .

It can be a hassle to integrate 3rd parties, but this link might be useful:

2 Likes

If you want to access everything in Office 365, Word, Excel, Outlook, Teams, PowerPoint, Sharepoint, Visio, Presentation, Project , … the best way is to use Microsoft Graph.

Microsoft Graph SDK for PHP

It’s base on REST, but it does need a very strong knowledge of Office 365

2 Likes

Thank you @aducom and @jlboutin60 !!

Hello

looking for someone to give me support for this, anyone interested?
please write me in private
thank you.

Hola

buscando alguien que me de soporte para esto, alguien interesado?
que me escriba por privado
gracias.

Hello
I give some progress, for example how to download a file from a sharepoint using the Microsoft Graph REST API (no library needed).
I recommend watching this video to know how to configure and pre-register the application in AzureAD and give API permissions correctly before running the code:

//site_id consists of site_id and web_id, separated by ,
//site id->https://xxxxxxxxxxxxxxx.sharepoint.com/sites/<<site_name>>/_api/site/id
//web_id->https://xxxxxxxxxxxxxxx.sharepoint.com/sites/<<site_name>>/_api/web/id

$access_token = getAccessToken($tenant_id, $client_id, $client_secret);

$file_url = “https://graph.microsoft.com/v1.0/sites/".$domain.",".$site_id."/drive/root:/”.$file_path;

$ch = curl_init($file_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Authorization: Bearer ’ . $access_token
));

$file_content = curl_exec($ch);

$file_data = json_decode($file_content, true);

if ($file_data && isset($file_data[’@microsoft.graph.downloadUrl’])) {
$download_url = $file_data[’@microsoft.graph.downloadUrl’];
} else {
echo “Error.”;
}

$file_info = curl_getinfo($ch);
curl_close($ch);

$file_content = file_get_contents($download_url);

if ($file_content !== false) {
file_put_contents($local_file_path, $file_content);

} else {
echo “Error.”;
}

function getAccessToken($tenant_id, $client_id, $client_secret) {
$token_url = “Sign in to your account”; //https://login.microsoftonline.com/$tenant_id/oauth2/v2.0/token
$token_data = array(
‘grant_type’ => ‘client_credentials’,
‘client_id’ => $client_id,
‘client_secret’ => $client_secret,
‘scope’ => ‘https://graph.microsoft.com/.default
);

$ch = curl_init($token_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($token_data));
$response = curl_exec($ch);
curl_close($ch);

$token_info = json_decode($response, true);
return $token_info['access_token'];

}