Sharepoint GetListItemChangesSinceToken CURL request in PHP
First approach
The following example demonstrates how to utilize GetListItemChangesSinceToken method
:
$listTitle = "Documents";$payload = array( 'query' => array( '__metadata' => array('type' => 'SP.ChangeLogItemQuery'), 'ViewName' => '', 'QueryOptions'=> '<QueryOptions><Folder>Shared Documents</Folder></QueryOptions>' ));$request = new ClientRequest($webUrl,$authCtx);$options = array( 'url' => $webUrl . "/_api/web/Lists/GetByTitle('$listTitle')/GetListItemChangesSinceToken", 'data' => json_encode($payload), 'method' => 'POST');$response = $request->executeQueryDirect($options);//process results$xml = simplexml_load_string($response);$xml->registerXPathNamespace('z', '#RowsetSchema');$rows = $xml->xpath("//z:row");foreach($rows as $row) { print (string)$row->attributes()["ows_FileLeafRef"] . "\n";}
Second approach
Since SharePoint REST Client SDK for PHP now supports GetListItemChangesSinceToken method
, the previous example could be invoked like this:
$list = $ctx->getWeb()->getLists()->getByTitle($listTitle);$query = new ChangeLogItemQuery();//to request all the items set ChangeToken property to null $query->ChangeToken = "1;3;e49a3225-13f6-47d4-a146-30d9caa05362;635969955256400000;10637059";$items = $list->getListItemChangesSinceToken($query);$ctx->executeQuery();foreach ($items->getData() as $item) { print "[List Item] $item->Title\r\n";}