11### About
2- Office 365 Library for PHP.
2+ Office 365 Library for PHP.
33A REST/OData based client library for Office 365.
44
55
6- ### Usage
6+ ### Usage
77
881 . [ Installation] ( #Installation )
992 . [ Working with SharePoint API] ( #Working-with-SharePoint-API )
10103 . [ Working with Teams API] ( #Working-with-Teams-API )
11- 4 . [ Working with Outlook API] ( #Working-with-Outlook-API )
11+ 4 . [ Working with Outlook API] ( #Working-with-Outlook-API )
12125 . [ Working with OneDrive API] ( #Working-with-OneDrive-API )
1313
1414
@@ -52,17 +52,17 @@ Finally, be sure to include the autoloader:
5252require_once '/path/to/your-project/vendor/autoload.php';
5353```
5454
55- #### Requirements
55+ #### Requirements
5656
57- PHP version: [ PHP 5.5 or later] ( https://secure .php.net/ )
57+ PHP version: [ PHP 7.1 or later] ( https://www .php.net/ )
5858
5959
6060#### Working with SharePoint API
6161
6262The list of supported SharePoint versions:
6363
6464- SharePoint Online and OneDrive for Business
65- - SharePoint On-Premises (2013-2019)
65+ - SharePoint On-Premises (2013-2019)
6666
6767#### Authentication
6868
@@ -74,7 +74,7 @@ The following auth flows supported:
7474
7575 use Office365\Runtime\Auth\ClientCredential;
7676 use Office365\SharePoint\ClientContext;
77-
77+
7878 $credentials = new ClientCredential("{clientId}", "{clientSecret}");
7979 $ctx = (new ClientContext("{siteUrl}"))->withCredentials($credentials);
8080```
@@ -83,26 +83,26 @@ The following auth flows supported:
8383- user credentials auth:
8484
8585``` php
86-
86+
8787 use Office365\Runtime\Auth\UserCredentials;
8888 use Office365\SharePoint\ClientContext;
89-
89+
9090 $credentials = new UserCredentials("{userName}", "{password}");
9191 $ctx = (new ClientContext("{siteUrl}"))->withCredentials($credentials);
9292```
93-
94-
93+
94+
9595- NTLM auth (for SharePoint On-Premises):
9696``` php
9797 use Office365\Runtime\Auth\UserCredentials;
9898 use Office365\SharePoint\ClientContext;
99-
99+
100100 $credentials = new UserCredentials("{userName}", "{password}");
101101 $ctx = (new ClientContext("{siteUrl}"))->withNtlm($credentials);
102-
102+
103103```
104104
105- #### Examples
105+ #### Examples
106106
107107The following examples demonstrates how to perform basic CRUD operations against ** SharePoint** list item resources:
108108
@@ -114,12 +114,12 @@ use Office365\Runtime\Auth\ClientCredential;
114114use Office365\SharePoint\ListItem;
115115
116116$credentials = new ClientCredential("{client-id}", "{client-secret}");
117- $client = (new ClientContext("https://{your-tenant-prefix}.sharepoint.com"))->withCredentials($credentials);
117+ $client = (new ClientContext("https://{your-tenant-prefix}.sharepoint.com"))->withCredentials($credentials);
118118
119119$web = $client->getWeb();
120120$list = $web->getLists()->getByTitle("{list-title}"); //init List resource
121- $items = $list->getItems(); //prepare a query to retrieve from the
122- $client->load($items); //save a query to retrieve list items from the server
121+ $items = $list->getItems(); //prepare a query to retrieve from the
122+ $client->load($items); //save a query to retrieve list items from the server
123123$client->executeQuery(); //submit query to SharePoint server
124124/** @var ListItem $item */
125125foreach($items as $item) {
@@ -136,14 +136,14 @@ use Office365\Runtime\Auth\ClientCredential;
136136use Office365\SharePoint\ListItem;
137137
138138$credentials = new ClientCredential("{client-id}", "{client-secret}");
139- $client = (new ClientContext("https://{your-tenant-prefix}.sharepoint.com"))->withCredentials($credentials);
139+ $client = (new ClientContext("https://{your-tenant-prefix}.sharepoint.com"))->withCredentials($credentials);
140140
141141$items = $client->getWeb()
142142 ->getLists()
143- ->getByTitle("{list-title}")
143+ ->getByTitle("{list-title}")
144144 ->getItems()
145145 ->get()
146- ->executeQuery();
146+ ->executeQuery();
147147/** @var ListItem $item */
148148foreach($items as $item) {
149149 print "Task: {$item->getProperty('Title')}\r\n";
@@ -211,7 +211,7 @@ function acquireToken()
211211{
212212 $tenant = "{tenant}.onmicrosoft.com";
213213 $resource = "https://graph.microsoft.com";
214-
214+
215215 $provider = new AADTokenProvider($tenant);
216216 return $provider->acquireTokenForPassword($resource, "{clientId}",
217217 new UserCredentials("{UserName}", "{Password}"));
@@ -229,7 +229,7 @@ $newTeam = $client->getTeams()->add($teamName)->executeQuery();
229229
230230Supported list of APIs:
231231
232- - [ Outlook REST API] ( https://msdn.microsoft.com/en-us/office/office365/api/use-outlook-rest-api#DefineOutlookRESTAPI )
232+ - [ Outlook REST API] ( https://msdn.microsoft.com/en-us/office/office365/api/use-outlook-rest-api#DefineOutlookRESTAPI )
233233 - [ Outlook Contacts REST API] ( https://msdn.microsoft.com/en-us/office/office365/api/contacts-rest-operations )
234234 - [ Outlook Calendar REST API] ( https://msdn.microsoft.com/en-us/office/office365/api/calendar-rest-operations )
235235 - [ Outlook Mail REST API] ( https://msdn.microsoft.com/en-us/office/office365/api/mail-rest-operations )
@@ -249,7 +249,7 @@ function acquireToken()
249249{
250250 $tenant = "{tenant}.onmicrosoft.com";
251251 $resource = "https://graph.microsoft.com";
252-
252+
253253 $provider = new AADTokenProvider($tenant);
254254 return $provider->acquireTokenForPassword($resource, "{clientId}",
255255 new UserCredentials("{UserName}", "{Password}"));
@@ -278,7 +278,7 @@ function acquireToken()
278278{
279279 $tenant = "{tenant}.onmicrosoft.com";
280280 $resource = "https://graph.microsoft.com";
281-
281+
282282 $provider = new AADTokenProvider($tenant);
283283 return $provider->acquireTokenForPassword($resource, "{clientId}",
284284 new UserCredentials("{UserName}", "{Password}"));
@@ -291,5 +291,3 @@ $client->executeQuery();
291291print $drive->getWebUrl();
292292
293293```
294-
295-
0 commit comments