PHP code example of delaneymethod / sharepoint-api

1. Go to this page and download the library: Download delaneymethod/sharepoint-api 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/ */

    

delaneymethod / sharepoint-api example snippets


use DelaneyMethod\Sharepoint\Client as SharepointClient;

$siteName = 'YOUR_TEAM_SITE_NAME';
$siteUrl = 'https://YOUR_SITE.sharepoint.com';
$publicUrl = 'https://YOUR_SITE.sharepoint.com/:i:/r/sites/YOUR_TEAM_SITE_NAME/Shared%20Documents'
$clientId = 'YOUR_CLIENT_ID';
$clientSecret = 'YOUR_CLIENT_SECRET';
$verify = false; // See http://docs.guzzlephp.org/en/stable/request-options.html#verify
$accessToken = 'YOUR_ACCESS_TOKEN';

$client = new SharepointClient($siteName, $siteUrl, $publicUrl, $clientId, $clientSecret, $verify, $accessToken);

// Create a folder
$client->createFolder($path);

// Delete a folder
$client->delete($path);

// Upload a file
$client->upload($path, $contents);