PhpSPO Versions Save

Microsoft 365 Library for PHP.

v3.1.2

3 weeks ago

Added

  • GraphServiceClient::withUserCredentials and GraphServiceClient::withClientSecret methods introduced

Fixed

  • #337: Don't try to retrieve next set of items when using an iterator, if no next items are expected to exist

v3.1.1

7 months ago

Changelog

  • SharePoint model updated to 16.0.24106.12014 version
  • import fixes (patches for 3.1.0 version)

v3.1.0

7 months ago

Changelog

  • support for authenticate SharePoint API via client certificate flow
  • validate access token response in GraphServiceClient

Example: how to authenticate SharePoint API via client certificate flow

$siteUrl = "https://contoso.sharepoint.com";  //site or web absolute url 
$tenant = "contoso.onmicrosoft.com"; //tenant id or name
$thumbprint = "--thumbprint goes here--";
$clientId = "--client app id goes here--";
$privateKetPath = "-- path to private.key file--"
$privateKey = file_get_contents($privateKetPath);

$ctx = (new ClientContext($siteUrl))->withClientCertificate(
    $tenant, $clientId, $privateKey, $thumbprint);

$whoami = $ctx->getWeb()->getCurrentUser()->get()->executeQuery();
print $whoami->getLoginName();

v3.0.3

10 months ago

Changelog

  • support for document sets in SharePoint API
  • fix addering issue with web resource

Example: create a Document Set

$credentials = new ClientCredential($clientId, $clientSecret);
$client = (new ClientContext($siteUrl))->withCredentials($credentials);

$docSetName = "Orders"; 
$lib = $client->getWeb()->defaultDocumentLibrary();
$docSet = DocumentSet::create($client, $lib->getRootFolder(), $docSetName)->executeQuery();
print($docSet->getProperty("ServerRelativeUrl"));

v3.0.2

1 year ago

Changelog

  • #325 PR: fix composer autoload issue by @menegain-mathieu

v3.0.1

1 year ago

Changelog

  • #300: add CcRecipients property to Message class by @DavidBrogli
  • #304: Http Response improvements by @lbuchs
  • #307 add example to obtain available fields of a list by @cweiske
  • #318 Support for custom curl options by @drml
  • ClientObjectCollection class enhancements, introduced getAll method by @vgrem

Example: read list items in a large list via getAll method:

$ctx = (new ClientContext($siteUrl))->withCredentials($credentials);
$list = $ctx->getWeb()->getLists()->getByTitle("--large list title--");

$allItems = $list->getItems()->getAll(5000, function ($returnType){
    print("{$returnType->getPageInfo()} items loaded...\n");
})->executeQuery();

v3.0.0

1 year ago

Changelog

  • #283: exception handling enhancements for authentication requests by @SuperDJ
  • #286: introduced client secret support for acquireTokenForPassword method in AADTokenProvider class by @R-Tech
  • #287 and #288: captures and validates if response failed by @fr3nch13
  • #297: remove minimum-stability from composer.json by @cweiske
  • #298 and #299: deprecation fixes for PHP 8 and drop PHP 5.5 requirement by @cweiske

v2.5.4

1 year ago

Changelog

v2.5.3

2 years ago

Changelog

  • SharePoint API: improved support for composite field values namely FieldLookupValue/FieldMultiLookupValue, FieldMultiChoiceValue , refer example 1 below ( related issues: #261)
  • OData request/response serialization optimizations (namely excluding metadata annotations from response by default)

Example : create list item and specify multi lookup & choice fields values:

$list = $ctx->getWeb()->getLists()->getByTitle("Tasks");

$taskProps = array(
    'Title' => "New task",
    'ParentTask' => new FieldLookupValue($taskLookupId),
    'PrimaryManager' => new FieldUserValue($userId),
    'Managers' => new FieldMultiLookupValue([$userId]),
    'TaskCategories' => new FieldMultiChoiceValue(["Event", "Reminder"])
);
$item = $list->addItem($taskProps)->executeQuery();

2.5.2

2 years ago

Changelog

  • introduced Reports namespace, refer official documentation for a more details
  • Outlook namespace model updates
  • SharePoint API: model updated to 16.0.21729.12001 version

Example: Get details about Microsoft 365 active users

Documentation: reportRoot: getOffice365ActiveUserDetail


use Office365\GraphServiceClient;
use Office365\Runtime\Auth\AADTokenProvider;
use Office365\Runtime\Auth\ClientCredential;


function acquireToken()
{
   $resource = "https://graph.microsoft.com";
   $provider = new AADTokenProvider($tenantName);
   return $provider->acquireTokenForClientCredential($resource,
       new ClientCredential($clientId, $clientSecret),["/.default"]);
}

$client = new GraphServiceClient("acquireToken");
$result = $client->getReports()->getOffice365ActivationCounts()->executeQuery();
var_dump($result->getValue());

$result = $client->getReports()->getOffice365ActiveUserDetail("D7")->executeQuery();
var_dump($result->getValue());