Configure phpSPO read

Job ID: 34704528

Budget: $10 – $30 USD

This project is about to configure phpSPO read (https://github.com/vgrem/phpSPO) to filter on dates. I use phpSPO to read items from sharepoint to php. My sharepoint list contains a date field that I would like to use when I read items from sharepoint.


=======================================================
Sharepoint list (name: sharepoint_list):
=======================================================
Title id useremail date from to
line1 1 XXXXXXXXXXXXXXXX 2022-09-10 12:00 13:00
line2 2 XXXXXXXXXXXXXXXX 2022-09-09 12:00 13:00
line3 3 XXXXXXXXXXXXXXXX 2022-09-08 12:00 13:00
line4 4 XXXXXXXXXXXXXXXX 2022-09-10 12:00 13:00
line5 5 XXXXXXXXXXXXXXXX 2022-09-11 12:00 13:00
line6 6 XXXXXXXXXXXXXXXX 2022-09-20 12:00 13:00
line7 7 XXXXXXXXXXXXXXXX 2022-09-10 12:00 13:00
line8 8 XXXXXXXXXXXXXXXX 2022-09-21 12:00 13:00
line9 9 XXXXXXXXXXXXXXXX 2022-09-10 12:00 13:00
line10 10 XXXXXXXXXXXXXXXX 2022-09-15 12:00 13:00



=======================================================
Requirements
=======================================================
The code I use to read items look like the code below. I would like to use filers to read an date intervall and order them in date order.

Ex: I would like to read date intervall (2022-09-10 - 2022-09-14). I should get:
line1 1 XXXXXXXXXXXXXXXX 2022-09-10 12:00 13:00
line4 4 XXXXXXXXXXXXXXXX 2022-09-10 12:00 13:00
line7 7 XXXXXXXXXXXXXXXX 2022-09-10 12:00 13:00
line9 9 XXXXXXXXXXXXXXXX 2022-09-10 12:00 13:00
line5 5 XXXXXXXXXXXXXXXX 2022-09-11 12:00 13:00


NOTE: I do NOT want to read all items from sharepoint and do the filtering in php! I would like to filter with the phpSPO query.



=======================================================
Delivery
=======================================================
php code that uses phpSPO to read items from sharepoint. The code use filters so filter on a date intervall. Order of the read items could be done in php or in the filter query.



=======================================================
Code
=======================================================
use Office365\SharePoint\ClientContext;
use Office365\Runtime\Auth\ClientCredential;
use Office365\SharePoint\ListItem;

$credentials = new ClientCredential("{client-id}", "{client-secret}");
$client = (new ClientContext("https://{your-tenant-prefix}.sharepoint.com"))->withCredentials($credentials);

$web = $client->getWeb();
$list = $web->getLists()->getByTitle("{list-title}"); //init List resource
$items = $list->getItems(); //prepare a query to retrieve from the. How do I make q query here?
$client->load($items); //save a query to retrieve list items from the server
$client->executeQuery(); //submit query to SharePoint server
/** @var ListItem $item */
foreach($items as $item) {
print "Task: {$item->getProperty('Title')}\r\n";
}
Related categories: PHP Sharepoint