Comment s'authentifier auprès de SharePoint Online pour une application PHP ?

ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Comment s'authentifier auprès de SharePoint Online pour une application PHP ?

Message par ForumBot »

Comment s’authentifier auprès de SharePoint Online pour une application PHP ?

ayi
Site Admin
Messages : 13176
Inscription : mer. avr. 22, 2026 5:21 pm

Re: Comment s'authentifier auprès de SharePoint Online pour une application PHP ?

Message par ayi »

SharePoint Online (SPO) prend en charge l’authentification basée sur les revendications.


L’image ci-dessous illustre comment l’authentification est effectuée dans SPO :


Selon cet article, le processus d’authentification consiste en les étapes suivantes :


Étapes :




  • Envoyer une requête SAML au STS




  • Recevoir la réponse SAML




  • Envoyer le jeton de sécurité à SharePoint Online




  • Recevoir les cookies d’authentification




  • Envoyer les requêtes en incluant les cookies d’authentification




phpSPO - Client SharePoint pour PHP prend en charge l’authentification SPO.


La bibliothèque fournit un client SharePoint Online (SPO) pour les applications PHP. Elle vous permet d’effectuer des opérations CRUD sur les données SharePoint en utilisant une API basée sur REST/OData de SharePoint 2013.


Exemples


Comment effectuer l’authentification dans SharePoint Online (SPO) :


try {
$client = new SPOClient($url);
$client->signIn($username,$password);
echo 'You have authenticated successfully\n';
}
catch (Exception $e) {
echo 'Authentication failed: ', $e->getMessage(), "\n";
}


L’exemple suivant montre comment effectuer des opérations CRUD sur les données d’une liste SharePoint :


<?php

require_once 'SPOClient.php';

$username = '[email protected]';
$password = 'password';
$url = "https://tenant.sharepoint.com/";

$client = new SPOClient($url);
$client->signIn($username,$password);

//Get Tasks list
$listTitle = 'Tasks';
$list = $client->getList($listTitle);

//Create a Task item
$itemProperties = array('Title' => 'Order Approval', 'Body' => 'Order approval task');
$taskItem = $list->addItem($itemProperties);
print "Task '{$taskItem->Title}' has been created succesfully.\r\n";

$itemId = $taskItem->Id;
//Update a Task item
$itemProperties = array('PercentComplete' => 1);
$list->updateItem($itemId,$itemProperties);

//Delete a Task item
$list->deleteItem($itemId);

?>


Références


[SharePoint Online client for PHP](http://blog.vgrem.com/2014/05/31/sharepo


(Réponse tronquée)

Répondre

Revenir à « OneDrive & SharePoint »