1
votes

I'm not familiar at all with SharePoint, I am trying to build a php script to browse and access files shared with us on a folder like this : https://blabla.sharepoint.com/:b:/r/sites/SubSiteName/Shared%20Documents/OurCompanyName/Invoice

I've found those libraries : https://github.com/vgrem/phpSPO and https://github.com/thybag/PHP-SharePoint-Lists-API, but I can't find the good way to access the files. I've also found posts speaking of php & SharePoint here, but none seems to match my need.

I've tried this code with phpSPO, but it fails at executeQuery() :

$authCtx = new AuthenticationContext('https://blabla.sharepoint.com');
$authCtx->acquireTokenForUser('our@email','password');
$ctx = new ClientContext('https://blabla.sharepoint.com',$authCtx);

$fileUrl = '/sites/SubSiteName/Shared Documents/OurCompanyName/Invoice/INV_123.PDF';
$file = $ctx->getWeb()->getFileByServerRelativeUrl($fileUrl);
$ctx->load($file);
$ctx->executeQuery();
print "File name: '{$file->getProperty("Name")}'\r\n";
1

1 Answers

0
votes

SharePoint has REST API that you can use to get specific file

url: http://site url/_api/web/GetFolderByServerRelativeUrl('/Folder Name')/Files('file name')/$value
method: GET