From 4c0bbe6219641d8ccfc0d82d26a16461e94c2e53 Mon Sep 17 00:00:00 2001 From: "vvgrem@gmail.com" Date: Wed, 19 Aug 2020 22:02:06 +0300 Subject: [PATCH] 2.4.2 release fixes and adjustments --- README.md | 23 +++++++------------ ...ppPrincipal.php => ConnectWithAppOnly.php} | 0 examples/SharePoint/FluentApi.php | 4 ++-- 3 files changed, 10 insertions(+), 17 deletions(-) rename examples/SharePoint/{ConnectOnlineWithAppPrincipal.php => ConnectWithAppOnly.php} (100%) diff --git a/README.md b/README.md index 85ac09ff..3d7755db 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ or via `composer.json` file: ```json { "require": { - "vgrem/php-spo": "^2.3" + "vgrem/php-spo": "^2.4" } } ``` @@ -69,19 +69,15 @@ The following auth flows supported: - app principals (client credentials) auth (refer [Granting access using SharePoint App-Only](https://docs.microsoft.com/en-us/sharepoint/dev/solution-guidance/security-apponly-azureacs) for a details): ``` - $authCtx = new AuthenticationContext($url); - $authCtx->acquireAppOnlyAccessToken($clientId,$clientSecret); - $ctx = new ClientContext($url,$authCtx); + $credentials = new ClientCredential($clientId, $clientSecret); + $ctx = (new ClientContext($url))->withCredentials($credentials); ``` - user credentials auth: ``` - - $authCtx = new AuthenticationContext($url); - $authCtx->acquireTokenForUser($username,$password); - $ctx = new ClientContext($url,$authCtx); - + $credentials = new UserCredentials($userName, $password); + $ctx = (new ClientContext($url))->withCredentials($credentials); ``` @@ -99,11 +95,8 @@ The following examples demonstrates how to perform basic CRUD operations against Example 1. How to read SharePoint list items ``` - -$authCtx = new AuthenticationContext($Url); -$authCtx->acquireTokenForUser($UserName,$Password); //authenticate - -$ctx = new ClientContext($Url,$authCtx); +$credentials = new ClientCredential($clientId, $clientSecret); +$ctx = (new ClientContext($url))->withCredentials($credentials); $web = $ctx->getWeb(); $list = $web->getLists()->getByTitle($listTitle); //init List resource $items = $list->getItems(); //prepare a query to retrieve from the @@ -168,7 +161,7 @@ The following example demonstrates how to send a message via Outlook Mail API: $message->Subject = "Meet for lunch?"; $message->Body = new ItemBody(BodyType::Text,"The new cafeteria is open."); $message->ToRecipients = array( - new Recipient(new EmailAddress(null,"vgrem@mediadev8.onmicrosoft.com")) + new Recipient(new EmailAddress(null,"jdoe@contoso.onmicrosoft.com")) ); $client->getMe()->sendEmail($message,true); $client->executeQuery(); diff --git a/examples/SharePoint/ConnectOnlineWithAppPrincipal.php b/examples/SharePoint/ConnectWithAppOnly.php similarity index 100% rename from examples/SharePoint/ConnectOnlineWithAppPrincipal.php rename to examples/SharePoint/ConnectWithAppOnly.php diff --git a/examples/SharePoint/FluentApi.php b/examples/SharePoint/FluentApi.php index 77b08491..2a35a9e2 100644 --- a/examples/SharePoint/FluentApi.php +++ b/examples/SharePoint/FluentApi.php @@ -2,7 +2,7 @@ use Office365\Runtime\Auth\ClientCredential; use Office365\SharePoint\ClientContext; -use Office365\SharePoint\ResourcePath; +use Office365\SharePoint\SPResourcePath; $settings = include('../../Settings.php'); @@ -13,7 +13,7 @@ $credentials = new ClientCredential($settings['ClientId'], $settings['ClientSecret']); $file = (new ClientContext($settings['Url']))->withCredentials($credentials) - ->getWeb()->getFileByServerRelativePath(new ResourcePath($fileUrl))->get()->executeQuery(); + ->getWeb()->getFileByServerRelativePath(new SPResourcePath($fileUrl))->get()->executeQuery(); print "File name: {$file->getName()}\r\n";