├── README.md
├── composer.json
├── example
├── callback.php
├── createfolder.php
├── download.php
├── footer.inc.php
├── header.inc.php
├── index.php
├── logout.php
├── properties.php
├── statics
│ ├── audio-icon.png
│ ├── file-icon.png
│ ├── folder-icon.png
│ ├── key-icon.png
│ ├── photo-icon.png
│ └── video-icon.png
├── tokens
└── upload.php
└── src
└── functions.inc.php
/README.md:
--------------------------------------------------------------------------------
1 | php-skydrive
2 | ============
3 |
4 | A PHP client library for Microsoft SkyDrive/OneDrive.
5 | This is very much a work in progress!
6 | See the Wiki for updates and documentation!
7 |
8 | Update 19-May-2014 - Composer.
9 | - By request, I've created a composer.json and published "lovattj/php-skydrive": "v1.0" on Packagist.
10 | - I've also added an autoloader definition.
11 | - I've not got much Composer or autoloading experience, so if it doesn't work please let me know!
12 |
13 | Update 18-May-2014 - IMPORTANT CHANGE.
14 | - `get_folder` now returns a multidimensional array.
15 | - `$array['data']` is now the array of files.
16 | - `$array['paging']` is an array of page tokens used for pagination.
17 | - Previous behavior was that `$array` on it's own was the array of files only.
18 | - Please update code accordingly and see the Wiki or example project for more information.
19 |
20 | Update 19-Feb-2014:
21 | - Yes! It works with OneDrive fine (new name for SkyDrive).
22 | - Added support for refresh tokens.
23 | - You can now build apps that don't require re-authentication every 60 minutes.
24 | - Also implemented functions to help you build a token store, to help you store tokens if you want to.
25 | - See the Wiki for more information - there are some major changes.
26 |
27 | Update 1-Nov-2013:
28 | - Converted into a Class
29 | - First, edit `functions.inc.php` and include your Live Client ID, Secret Key and oAuth callback URL.
30 | - Call `skydrive_auth::build_oauth_url();` to obtain an oAuth URL.
31 | - Redirect your user to that URL, then call `skydrive_auth::get_oauth_token($_GET['code']);` on the callback to obtain an access token.
32 | - Once you have an access token, create a new object - `$sd = new skydrive($access_token);`.
33 | - Then call the specified method - `$response = $sd->get_folder();`
34 | - Exceptions will be thrown when a non-200 HTTP status code is encountered.
35 | - I'll update the Wiki with new class documentation. Thanks!
36 |
37 | System Requirements:
38 | - PHP 5 (I tested with 5.3.3)
39 | - cURL extension for PHP
40 |
41 | How to install manually:
42 | - Clone project
43 | - Edit "src/functions.inc.php" and include your Live Client ID, Secret Key and oAuth callback URL in relevant places.
44 | - Require "src/functions.inc.php", create an object and start calling functions!
45 |
46 | How to install via Composer:
47 | - Require "lovattj/php-skydrive": "v1.0" in your composer.json
48 | - Edit "vendor/lovattj/php-skydrive/src/functions.inc.php" and include your Live Client ID, Secret Key and oAuth callback URL in relevant places.
49 | - Require "vendor/lovattj/php-skydrive/src/functions.inc.php", create an object and start calling functions!
50 |
51 | How to get the example running:
52 | - Deploy to your web server
53 | - Make sure the file "example/tokens" is read+writable by your web user.
54 | - Edit "src/functions.inc.php" and include your Live Client ID, Secret Key and oAuth callback URL in relevant places.
55 | - Hit "example/index.php" and follow the prompts to login with SkyDrive!
56 |
57 | Questions/Comments:
58 | - E-Mail me at php-skydrive@jlls.info
59 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "lovattj/php-skydrive",
3 | "description": "A PHP client library for Microsoft SkyDrive/OneDrive",
4 | "type": "library",
5 | "keywords": ["api","skydrive","onedrive","microsoft","php","client"],
6 | "homepage": "https://github.com/lovattj/php-onedrive",
7 | "license": "GPL",
8 | "authors": [
9 | {
10 | "name": "Jonathan Lovatt",
11 | "email": "php-skydrive@jlls.info",
12 | "homepage": "http://jlls.info",
13 | "role": "Developer"
14 | }
15 | ],
16 | "require": {
17 | "php": ">=5.3.0"
18 | },
19 | "autoload": {
20 | "classmap": ["src/"]
21 |
22 | }
23 | }
--------------------------------------------------------------------------------
/example/callback.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/example/createfolder.php:
--------------------------------------------------------------------------------
1 | ";
10 | echo "
 ";
11 | echo "Login with SkyDrive";
12 | echo "";
13 |
14 | } else {
15 |
16 | if (empty($_POST['foldername'])) {
17 | echo 'Error - no new folder name specified';
18 | } else {
19 | $sd = new skydrive($token);
20 | try {
21 | if (empty($_POST['currentfolderid'])) {
22 | $response = $sd->create_folder(null, $_POST['foldername'], 'Description');
23 | } else {
24 | $response = $sd->create_folder($_POST['currentfolderid'], $_POST['foldername'], 'Description');
25 | }
26 | // Folder was created, return metadata.
27 | print_r($response);
28 | } catch (Exception $e) {
29 | // An error occured, print HTTP status code and description.
30 | echo "Error: ".$e->getMessage();
31 | exit;
32 | }
33 | }
34 |
35 |
36 | }
37 | require_once "footer.inc.php";
38 | ?>
--------------------------------------------------------------------------------
/example/download.php:
--------------------------------------------------------------------------------
1 | download($_GET['fileid']);
11 | ob_end_clean();
12 | header('Content-Type: application/octet-stream');
13 | header('Content-Length: '.$response[0]['properties']['size']);
14 | header('Content-Description: File Transfer');
15 | header('Content-Disposition: attachment; filename='.$response[0]['properties']['name']);
16 | $stdout = fopen('php://output', 'r+');
17 | fwrite($stdout, $response[0]['data']);
18 | } catch (Exception $e) {
19 | // An error occured, print HTTP status code and description.
20 | echo "Error: ".$e->getMessage();
21 | exit;
22 | }
23 | }
24 | require_once "footer.inc.php";
25 | ?>
--------------------------------------------------------------------------------
/example/footer.inc.php:
--------------------------------------------------------------------------------
1 |