All Projects → vgrem → Phpspo

vgrem / Phpspo

Licence: mit
Office 365 Library for PHP. It allows to performs CRUD operations against Office 365 resources via an REST/OData based API

Projects that are alternatives of or similar to Phpspo

vbo365-rest-self-service
Unofficial Self-Service Web Portal for Veeam Backup for Microsoft Office 365
Stars: ✭ 24 (-87.88%)
Mutual labels:  onedrive, sharepoint, office365
Microsoft365dsc
Manages, configures, extracts and monitors Microsoft 365 tenant configurations
Stars: ✭ 374 (+88.89%)
Mutual labels:  sharepoint, office365, onedrive
Office365 Rest Python Client
Office 365 & Microsoft Graph Library for Python
Stars: ✭ 289 (+45.96%)
Mutual labels:  sharepoint, office365, onedrive
vbo365-rest
Unofficial Self-Service Web Portal for Veeam Backup for Microsoft Office 365
Stars: ✭ 44 (-77.78%)
Mutual labels:  onedrive, sharepoint, office365
OneManager-cfworkerskv
部署在cloudflare的workers中的OneManager。
Stars: ✭ 124 (-37.37%)
Mutual labels:  onedrive, sharepoint
gulp-spsync
Gulp plugin for synchronizing local files with a SharePoint library
Stars: ✭ 57 (-71.21%)
Mutual labels:  sharepoint, office365
Keepassonedrivesync
Allows syncing of KeePass databases stored on OneDrive Personal, OneDrive for Business or SharePoint
Stars: ✭ 270 (+36.36%)
Mutual labels:  sharepoint, onedrive
Cli Microsoft365
Manage Microsoft 365 and SharePoint Framework projects on any platform
Stars: ✭ 420 (+112.12%)
Mutual labels:  sharepoint, office365
O365 SPO PowerShellScripts
PowerShell scripts related to SharePoint Online in Microsoft 365
Stars: ✭ 22 (-88.89%)
Mutual labels:  sharepoint, office365
Onedrive
#1 Free OneDrive Client for Linux
Stars: ✭ 5,104 (+2477.78%)
Mutual labels:  office365, onedrive
Python O365
A simple python library to interact with Microsoft Graph and Office 365 API
Stars: ✭ 742 (+274.75%)
Mutual labels:  sharepoint, onedrive
onedrive user enum
onedrive user enumeration - pentest tool to enumerate valid onedrive users
Stars: ✭ 223 (+12.63%)
Mutual labels:  onedrive, office365
powershell
PnP PowerShell
Stars: ✭ 326 (+64.65%)
Mutual labels:  sharepoint, office365
Onemanager Php
An index & manager of Onedrive based on serverless. Can be deployed to Heroku/Glitch/SCF/FG/FC/CFC/PHP web hosting/VPS.
Stars: ✭ 1,313 (+563.13%)
Mutual labels:  sharepoint, onedrive
Cyberduck
Cyberduck is a libre FTP, SFTP, WebDAV, Amazon S3, Backblaze B2, Microsoft Azure & OneDrive and OpenStack Swift file transfer client for Mac and Windows.
Stars: ✭ 1,080 (+445.45%)
Mutual labels:  sharepoint, onedrive
Onedrive Php Sdk
OneDrive SDK for PHP
Stars: ✭ 104 (-47.47%)
Mutual labels:  onedrive, sdk
Pnp Sites Core
Microsoft 365 Dev PnP Core component (.NET) targeted for increasing developer productivity with CSOM based solutions.
Stars: ✭ 411 (+107.58%)
Mutual labels:  sharepoint, office365
Office365FiddlerExtension
This Fiddler Extension is an Office 365 centric parser to efficiently troubleshoot Office 365 client application connectivity and functionality.
Stars: ✭ 23 (-88.38%)
Mutual labels:  onedrive, office365
Generator Spfx
Open-source generator to extend the capabilities of the Microsoft SPFx generator
Stars: ✭ 150 (-24.24%)
Mutual labels:  sharepoint, office365
React Application Injectcss
An SPFx extension that injects CSS on every page
Stars: ✭ 20 (-89.9%)
Mutual labels:  sharepoint, office365

About

Office 365 Library for PHP. A REST/OData based client library for Office 365.

Usage

  1. Installation
  2. Working with SharePoint API
  3. Working with Outlook API
  4. Working with OneDrive API

Status

Total Downloads Latest Stable Version Build Status License

Installation

You can use Composer or simply Download the Release

Composer

The preferred method is via composer. Follow the installation instructions if you do not already have composer installed.

Once composer installed, execute the following command in your project root to install this library:

composer require vgrem/php-spo

or via composer.json file:

{
    "require": {
        "vgrem/php-spo": "^2.4"
    }
}

Finally, be sure to include the autoloader:

require_once '/path/to/your-project/vendor/autoload.php';

Requirements

PHP version: PHP 5.5 or later

Working with SharePoint API

The list of supported SharePoint versions:

  • SharePoint Online and OneDrive for Business
  • SharePoint On-Premises (2013-2019)

Authentication

The following auth flows supported:

  • app principals (client credentials) auth (refer Granting access using SharePoint App-Only for a details):

    $credentials = new ClientCredential($clientId, $clientSecret);
    $ctx = (new ClientContext($url))->withCredentials($credentials);
    
  • user credentials auth:

    $credentials = new UserCredentials($userName, $password);
    $ctx = (new ClientContext($url))->withCredentials($credentials);
    
  • NTLM auth (for SharePoint On-Premises):

     $authCtx = new NetworkCredentialContext($username, $password);
     $authCtx->AuthType = CURLAUTH_NTLM;
     $ctx = new ClientContext($url,$authCtx);
    

Examples

The following examples demonstrates how to perform basic CRUD operations against SharePoint list item resources:

Example 1. How to read SharePoint list items:

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 
$client->load($items);  //save a query to retrieve list items from the server 
$client->executeQuery(); //submit query to SharePoint Online REST service
/** @var ListItem $item */
foreach($items as $item) {
    print "Task: {$item->getProperty('Title')}\r\n";
}

or via Fluent API syntax:

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);     

$items = $client->getWeb()
                ->getLists()
                ->getByTitle("{list-title}") 
                ->getItems()
                ->get()
                ->executeQuery();      
/** @var ListItem $item */
foreach($items as $item) {
    print "Task: {$item->getProperty('Title')}\r\n";
}

Example 2. How to create SharePoint list item:

use Office365\SharePoint\ClientContext;
use Office365\Runtime\Auth\ClientCredential;

$credentials = new ClientCredential("{client-id}", "{client-secret}");
$client = (new ClientContext("https://{your-tenant-prefix}.sharepoint.com"))->withCredentials($credentials);

$list = $client->getWeb()->getLists()->getByTitle("Tasks");
$itemProperties = array('Title' => 'Order Approval', 'Body' => 'Order approval task');
$item = $list->addItem($itemProperties);
$client->executeQuery();
print "Task {$item->getProperty('Title')} has been created.\r\n";

Example 3. How to delete a SharePoint list item:

use Office365\SharePoint\ClientContext;
use Office365\Runtime\Auth\ClientCredential;

$credentials = new ClientCredential("{client-id}", "{client-secret}");
$client = (new ClientContext("https://{your-tenant-prefix}.sharepoint.com"))->withCredentials($credentials);

$list = $client->getWeb()->getLists()->getByTitle("Tasks");
$listItem = $list->getItemById("{item-id-to-delete}");
$listItem->deleteObject();
$client->executeQuery();

Example 4. How to update SharePoint list item:

use Office365\SharePoint\ClientContext;
use Office365\Runtime\Auth\ClientCredential;

$credentials = new ClientCredential("{client-id}", "{client-secret}");
$client = (new ClientContext("https://{your-tenant-prefix}.sharepoint.com"))->withCredentials($credentials);

$list = $client->getWeb()->getLists()->getByTitle("Tasks");
$listItem = $list->getItemById("{item-id-to-update}");
$listItem->setProperty('PercentComplete',1);
$listItem->update();
$client->executeQuery();

Working with Outlook API

Supported list of APIs:

The following example demonstrates how to send a message via Outlook Mail API:

 use Office365\Runtime\Auth\AuthenticationContext;
 use Office365\OutlookServices\OutlookClient;
 use Office365\OutlookServices\ItemBody;
 use Office365\OutlookServices\BodyType;
 use Office365\OutlookServices\EmailAddress;
 use Office365\OutlookServices\Recipient;

 $tenantNameOrId = "{tenant}.onmicrosoft.com";
 $client = new OutlookClient($tenantNameOrId,function (AuthenticationContext $authCtx) {        
        $authCtx->setAccessToken("--access token goes here--");
 });

 $message = $client->getMe()->getMessages()->createMessage();
 $message->Subject = "Meet for lunch?";
 $message->Body = new ItemBody(BodyType::Text,"The new cafeteria is open.");
 $message->ToRecipients = array(
     new Recipient(new EmailAddress(null,"{username}@{tenant_prefix}.onmicrosoft.com"))
 );
 $client->getMe()->sendEmail($message,true);
 $client->executeQuery();


Working with OneDrive API

The following example demonstrates how retrieve My drive Url via OneDrive API:

use Office365\Runtime\Auth\AuthenticationContext;
use Office365\Graph\GraphServiceClient;

$tenantNameOrId = "{tenant}.onmicrosoft.com";
$client = new GraphServiceClient($tenantNameOrId,function (AuthenticationContext $authCtx) {
      $authCtx->setAccessToken("{access-token}");
});

$drive = $client->getMe()->getDrive();
$client->load($drive);
$client->executeQuery();
print $drive->getProperty("webUrl");

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].