Version 2.4.5
Changelog
-
#231: introduced support for
IPResolve
andForbidReuse
options forRequestOptions
class by @tommy2d -
various bug fixes, including #230
-
SharePoint API support for Taxonomy namespace, refer example 1 below
-
SharePoint API model has been updated to
16.0.21221.12006
-
fluent API improvements, a simplified way to initialize
GraphServiceClient
andOutlookClient
clients by passing acquire token function,AADTokenProvider
class which contains built-in support for Client credentials, Username/password flows, refer example 2 below
Examples
Example 1: export taxonomy data via SharePoint API
use Office365\Runtime\Auth\ClientCredential;
use Office365\SharePoint\ClientContext;
use Office365\SharePoint\Taxonomy\TaxonomyService;
use Office365\SharePoint\Taxonomy\TermGroup;
$appPrincipal = new ClientCredential($clientId,$clientSecret);
$ctx = (new ClientContext($settings['Url']))->withCredentials($appPrincipal);
$taxSvc = new TaxonomyService($ctx);
$groups = $taxSvc->getTermStore()->getTermGroups()->get()->executeQuery();
$fp = fopen('./SiteTaxonomy.csv', 'w');
/** @var TermGroup $group */
foreach ($groups as $group){
fputcsv($fp, $group->toJson());
}
fclose($fp);
Example 2: Initialize Graph client
use Office365\Graph\GraphServiceClient;
use Office365\Runtime\Auth\AADTokenProvider;
use Office365\Runtime\Auth\UserCredentials;
function acquireToken()
{
$tenant = "{tenant}.onmicrosoft.com";
$resource = "https://graph.microsoft.com";
$provider = new AADTokenProvider($tenant);
return $provider->acquireTokenForPassword($resource, "{clientId}",
new UserCredentials("{UserName}", "{Password}"));
}
$client = new GraphServiceClient("acquireToken");