1. Go to this page and download the library: Download gwsn/sharepoint-sdk library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
gwsn / sharepoint-sdk example snippets
php
// Initialize the drive
$spDrive = new DriveService($accessToken);
$driveId = $spDrive->requestDriveId($siteId);
$spDrive->setDriveId($driveId);
// Check if Resource exists
try {
$result = $spDrive->checkResourceExists('/test');
var_dump($result);
$result = $spDrive->checkResourceExists('/testDoc.docx');
var_dump($result);
} catch (\Exception $exception) {
var_dump($exception->getMessage());
}
// move file /test.txt to folder /test and rename it to testje.txt
$result = $spFileService->moveFile('/test.txt', '/test', 'testje.txt');
// check if it still exists
$result = $spDrive->checkResourceExists('/test.txt');
var_dump($result);
// check if new file exists
$result = $spDrive->checkResourceExists('/test/testje.txt');
var_dump($result);