1
1
### About
2
- Office 365 Library for PHP.
2
+ Office 365 Library for PHP.
3
3
A REST/OData based client library for Office 365.
4
4
5
5
6
- ### Usage
6
+ ### Usage
7
7
8
8
1 . [ Installation] ( #Installation )
9
9
2 . [ Working with SharePoint API] ( #Working-with-SharePoint-API )
10
10
3 . [ 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 )
12
12
5 . [ Working with OneDrive API] ( #Working-with-OneDrive-API )
13
13
14
14
@@ -52,17 +52,17 @@ Finally, be sure to include the autoloader:
52
52
require_once '/path/to/your-project/vendor/autoload.php';
53
53
```
54
54
55
- #### Requirements
55
+ #### Requirements
56
56
57
- PHP version: [ PHP 5.5 or later] ( https://secure .php.net/ )
57
+ PHP version: [ PHP 7.1 or later] ( https://www .php.net/ )
58
58
59
59
60
60
#### Working with SharePoint API
61
61
62
62
The list of supported SharePoint versions:
63
63
64
64
- SharePoint Online and OneDrive for Business
65
- - SharePoint On-Premises (2013-2019)
65
+ - SharePoint On-Premises (2013-2019)
66
66
67
67
#### Authentication
68
68
@@ -74,7 +74,7 @@ The following auth flows supported:
74
74
75
75
use Office365\Runtime\Auth\ClientCredential;
76
76
use Office365\SharePoint\ClientContext;
77
-
77
+
78
78
$credentials = new ClientCredential("{clientId}", "{clientSecret}");
79
79
$ctx = (new ClientContext("{siteUrl}"))->withCredentials($credentials);
80
80
```
@@ -83,26 +83,26 @@ The following auth flows supported:
83
83
- user credentials auth:
84
84
85
85
``` php
86
-
86
+
87
87
use Office365\Runtime\Auth\UserCredentials;
88
88
use Office365\SharePoint\ClientContext;
89
-
89
+
90
90
$credentials = new UserCredentials("{userName}", "{password}");
91
91
$ctx = (new ClientContext("{siteUrl}"))->withCredentials($credentials);
92
92
```
93
-
94
-
93
+
94
+
95
95
- NTLM auth (for SharePoint On-Premises):
96
96
``` php
97
97
use Office365\Runtime\Auth\UserCredentials;
98
98
use Office365\SharePoint\ClientContext;
99
-
99
+
100
100
$credentials = new UserCredentials("{userName}", "{password}");
101
101
$ctx = (new ClientContext("{siteUrl}"))->withNtlm($credentials);
102
-
102
+
103
103
```
104
104
105
- #### Examples
105
+ #### Examples
106
106
107
107
The following examples demonstrates how to perform basic CRUD operations against ** SharePoint** list item resources:
108
108
@@ -114,12 +114,12 @@ use Office365\Runtime\Auth\ClientCredential;
114
114
use Office365\SharePoint\ListItem;
115
115
116
116
$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);
118
118
119
119
$web = $client->getWeb();
120
120
$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
123
123
$client->executeQuery(); //submit query to SharePoint server
124
124
/** @var ListItem $item */
125
125
foreach($items as $item) {
@@ -136,14 +136,14 @@ use Office365\Runtime\Auth\ClientCredential;
136
136
use Office365\SharePoint\ListItem;
137
137
138
138
$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);
140
140
141
141
$items = $client->getWeb()
142
142
->getLists()
143
- ->getByTitle("{list-title}")
143
+ ->getByTitle("{list-title}")
144
144
->getItems()
145
145
->get()
146
- ->executeQuery();
146
+ ->executeQuery();
147
147
/** @var ListItem $item */
148
148
foreach($items as $item) {
149
149
print "Task: {$item->getProperty('Title')}\r\n";
@@ -211,7 +211,7 @@ function acquireToken()
211
211
{
212
212
$tenant = "{tenant}.onmicrosoft.com";
213
213
$resource = "https://graph.microsoft.com";
214
-
214
+
215
215
$provider = new AADTokenProvider($tenant);
216
216
return $provider->acquireTokenForPassword($resource, "{clientId}",
217
217
new UserCredentials("{UserName}", "{Password}"));
@@ -229,7 +229,7 @@ $newTeam = $client->getTeams()->add($teamName)->executeQuery();
229
229
230
230
Supported list of APIs:
231
231
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 )
233
233
- [ Outlook Contacts REST API] ( https://msdn.microsoft.com/en-us/office/office365/api/contacts-rest-operations )
234
234
- [ Outlook Calendar REST API] ( https://msdn.microsoft.com/en-us/office/office365/api/calendar-rest-operations )
235
235
- [ Outlook Mail REST API] ( https://msdn.microsoft.com/en-us/office/office365/api/mail-rest-operations )
@@ -249,7 +249,7 @@ function acquireToken()
249
249
{
250
250
$tenant = "{tenant}.onmicrosoft.com";
251
251
$resource = "https://graph.microsoft.com";
252
-
252
+
253
253
$provider = new AADTokenProvider($tenant);
254
254
return $provider->acquireTokenForPassword($resource, "{clientId}",
255
255
new UserCredentials("{UserName}", "{Password}"));
@@ -278,7 +278,7 @@ function acquireToken()
278
278
{
279
279
$tenant = "{tenant}.onmicrosoft.com";
280
280
$resource = "https://graph.microsoft.com";
281
-
281
+
282
282
$provider = new AADTokenProvider($tenant);
283
283
return $provider->acquireTokenForPassword($resource, "{clientId}",
284
284
new UserCredentials("{UserName}", "{Password}"));
@@ -291,5 +291,3 @@ $client->executeQuery();
291
291
print $drive->getWebUrl();
292
292
293
293
```
294
-
295
-
0 commit comments