PHPackages                             efisiobova/onedrive-php-api - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. efisiobova/onedrive-php-api

ActiveLibrary[API Development](/categories/api)

efisiobova/onedrive-php-api
===========================

OneDrive library for PHP.

3252PHP

Since Jan 6Pushed 9y ago1 watchersCompare

[ Source](https://github.com/efisiobova/onedrive-php-api)[ Packagist](https://packagist.org/packages/efisiobova/onedrive-php-api)[ RSS](/packages/efisiobova-onedrive-php-api/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

OneDrive SDK for PHP
====================

[](#onedrive-sdk-for-php)

[![Latest Stable Version](https://camo.githubusercontent.com/87425b4403e60419231df5fb04608ddd3f6d03d48026719bf4124a2891d8020c/68747470733a2f2f706f7365722e707567782e6f72672f45666973696f626f76612f6f6e6564726976652d7068702d73646b2f762f737461626c65)](https://packagist.org/packages/Efisiobova/onedrive-php-sdk)[![Build Status](https://camo.githubusercontent.com/8e048906527a9963177b646665ca95818865db1de0a4862df04c8eae8680ded7/68747470733a2f2f7472617669732d63692e6f72672f45666973696f626f76612f6f6e6564726976652d7068702d73646b2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Efisiobova/onedrive-php-sdk)[![Code Coverage](https://camo.githubusercontent.com/2894ba6bc6e0eaff0450e825a0bc0587c0d6fe0f49d1abd487a9cd0bb20724ce/68747470733a2f2f636f6465636f762e696f2f67682f45666973696f626f76612f6f6e6564726976652d7068702d73646b2f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/Efisiobova/onedrive-php-sdk)[![StyleCI](https://camo.githubusercontent.com/3c5a3cefd698a760a5bbea54d7a4def33d7ec8e7a4a535020f5c4e0de879ce63/68747470733a2f2f7374796c6563692e696f2f7265706f732f32333939343438392f736869656c643f7374796c653d666c6174)](https://styleci.io/repos/23994489)

OneDrive SDK for PHP is an open source library that allows [PHP](http://php.net/)applications to interact programmatically with the [OneDrive API](http://msdn.microsoft.com/en-us/library/hh826521.aspx).

It supports operations such as creating, reading, updating, deleting (CRUD) files and folders, as well as moving or copying them to other folders.

Requirements
------------

[](#requirements)

Using the OneDrive SDK for PHP requires the following:

- [PHP](http://php.net/) 5.4 or newer
- The [cURL extension for PHP](http://php.net/manual/en/book.curl.php)
- [Composer](https://getcomposer.org/) 1.0.0-alpha10 or newer
- Basic PHP knowledge

Installation
------------

[](#installation)

To install the OneDrive SDK for PHP, copy the `onedrive-php-sdk` folder in your application source tree. The `example` subfolder contains example files and may be removed from production servers.

Configuration
-------------

[](#configuration)

To use this SDK, you need to register a OneDrive application. To do this, first [sign in to your Microsoft account](https://login.live.com/), then visit your [application manager](https://account.live.com/developers/applications/index) and [create an application](https://account.live.com/developers/applications/create).

Once done, your application will be assigned, among other things, a *Client ID*and a *Client secret*. These two values will be needed shortly to configure the OneDrive SDK for PHP.

You also need to create a web page where users will get redirected after they successfully signed in to their OneDrive account using this SDK. Typically, this will page will be a PHP script where you will start to interact with the files and folders stored in their OneDrive account. The URL of this page is the *Callback URI* and will also be needed to configure the OneDrive SDK for PHP.

Quick start
-----------

[](#quick-start)

Once you got your *Client ID*, *Client secret* and *Callback URI*, you can get started using the OneDrive SDK for PHP in three steps.

### Step 1: get your dependencies through Composer

[](#step-1-get-your-dependencies-through-composer)

From the root of this repository, get the required dependencies using [Composer](https://getcomposer.org/):

```
$ composer install -n

```

During the process, a `vendor/autoload.php` file will be created. It is mentioned in next steps and allows you to use classes from OneDrive SDK for PHP without needing to explicitly `require()` files that define them.

### Step 2: save your configuration

[](#step-2-save-your-configuration)

As you may need them from several scripts, save your *Client ID*, *Client secret* and *Callback URI* in a configuration file. Let's call it `onedrive-config.php` and fill it with:

```

```

### Step 3: direct your users to the sign in page

[](#step-3-direct-your-users-to-the-sign-in-page)

This script is responsible for, given a set of privileges, fetching a login URL from the OneDrive API. It then needs to guide the users to this URL so they initiate their log in and privilege granting process. The script should look like (replace `/path/to` by the appropriate values):

```
