Skip to content

Commit

Permalink
2.4.2 release fixes and adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
vvgrem@gmail.com authored and vvgrem@gmail.com committed Aug 19, 2020
1 parent 2184dc1 commit 4c0bbe6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 17 deletions.
23 changes: 8 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ or via `composer.json` file:
```json
{
"require": {
"vgrem/php-spo": "^2.3"
"vgrem/php-spo": "^2.4"
}
}
```
Expand Down Expand Up @@ -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);
```


Expand All @@ -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
Expand Down Expand Up @@ -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();
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions examples/SharePoint/FluentApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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";

Expand Down

0 comments on commit 4c0bbe6

Please sign in to comment.