phpSPO icon indicating copy to clipboard operation
phpSPO copied to clipboard

Read items from sharepoint

Open BeginnerRaffe opened this issue 1 year ago • 1 comments

Hello,

I have read that are some issues to read may items from sharepoint? I have tested with 500 and it seams to work for me. Are there any limitations how many items you can read?

I would like to make a query when I read from sharepoint. I got a date field in my sharepoint list and I would like only to read the items that is newer than a specific date. It that possible? (My sharepoint lits will contain many items ...)

I use the code below:

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"; }

BeginnerRaffe avatar Sep 16 '22 12:09 BeginnerRaffe