title: How to access shared files on SharePoint in PHP?
body: <p>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 : <a href="https://blabla.sharepoint.com/:b:/r/sites/SubSiteName/Shared%20Documents/OurCompanyName/Invoice" rel="nofollow noreferrer">https://blabla.sharepoint.com/:b:/r/sites/SubSiteName/Shared%20Documents/OurCompanyName/Invoice</a></p>
  
  <p>I've found those libraries : <a href="https://github.com/vgrem/phpSPO" rel="nofollow noreferrer">https://github.com/vgrem/phpSPO</a> and <a href="https://github.com/thybag/PHP-SharePoint-Lists-API" rel="nofollow noreferrer">https://github.com/thybag/PHP-SharePoint-Lists-API</a>, but I can't find the good way to access the files.
  I've also found posts speaking of php &amp; SharePoint here, but none seems to match my need.</p>
  
  <p>I've tried this code with phpSPO, but it fails at executeQuery() :</p>
  
  <pre class="lang-php prettyprint-override"><code>$authCtx = new AuthenticationContext('https://blabla.sharepoint.com');
  $authCtx-&gt;acquireTokenForUser('our@email','password');
  $ctx = new ClientContext('https://blabla.sharepoint.com',$authCtx);
  
  $fileUrl = '/sites/SubSiteName/Shared Documents/OurCompanyName/Invoice/INV_123.PDF';
  $file = $ctx-&gt;getWeb()-&gt;getFileByServerRelativeUrl($fileUrl);
  $ctx-&gt;load($file);
  $ctx-&gt;executeQuery();
  print "File name: '{$file-&gt;getProperty("Name")}'\r\n";
  </code></pre>