<?php require_once __DIR__ . '/../vendor/autoload.php'; use Krizalys\Onedrive\Client; session_start(); try { if (!array_key_exists('onedrive.client.state', $_SESSION)) { throw new \Exception('onedrive.client.state undefined in session'); } $onedrive = new Client(array('state' => $_SESSION['onedrive.client.state'])); $id = empty($_GET['id']) ? null : $_GET['id']; $folder = $onedrive->fetchObject($id); $objects = $folder->fetchObjects(); $status = null; } catch (\Exception $e) { $folder = null; $objects = null; $status = sprintf('<p class=bg-danger>Reason: <cite>%s</cite><p>', htmlspecialchars($e->getMessage())); } ?> <!DOCTYPE html> <html lang=en dir=ltr> <head> <meta charset=utf-8> <title>Fetching a OneDrive folder – Demonstration of the OneDrive SDK for PHP</title> <link rel=stylesheet href=//ajax.aspnetcdn.com/ajax/bootstrap/3.2.0/css/bootstrap.min.css> <link rel=stylesheet href=//ajax.aspnetcdn.com/ajax/bootstrap/3.2.0/css/bootstrap-theme.min.css> <meta name=viewport content="width=device-width, initial-scale=1"> </head> <body> <div class=container>
session_start(); try { if (!array_key_exists('onedrive.client.state', $_SESSION)) { throw new \Exception('onedrive.client.state undefined in session'); } $onedrive = new Client(array('state' => $_SESSION['onedrive.client.state'])); if (!array_key_exists('name', $_GET)) { throw new \Exception('name undefined in $_GET'); } if (!array_key_exists('content', $_GET)) { throw new \Exception('content undefined in $_GET'); } $options = array_key_exists('name_conflict_behavior', $_GET) ? array('name_conflict_behavior' => $_GET['name_conflict_behavior']) : array(); $parentId = empty($_GET['parent_id']) ? null : $_GET['parent_id']; $name = $_GET['name']; $parent = $onedrive->fetchObject($parentId); $file = $parent->createFile($name, $_GET['content'], $options); $status = sprintf('<p class=bg-success>The file <em>%s</em> has been created using the <code>Object::createFile</code> method.</p>', htmlspecialchars($name)); } catch (\Exception $e) { $file = null; $status = sprintf('<p class=bg-danger>The file <em>%s</em> has <strong>not</strong> been created using the <code>Object::createFile</code> method. Reason: <cite>%s</cite></p>', htmlspecialchars($name), $e->getMessage()); } ?> <!DOCTYPE html> <html lang=en dir=ltr> <head> <meta charset=utf-8> <title>Creating a OneDrive file – Demonstration of the OneDrive SDK for PHP</title> <link rel=stylesheet href=//ajax.aspnetcdn.com/ajax/bootstrap/3.2.0/css/bootstrap.min.css> <link rel=stylesheet href=//ajax.aspnetcdn.com/ajax/bootstrap/3.2.0/css/bootstrap-theme.min.css> <meta name=viewport content="width=device-width, initial-scale=1">
if (!array_key_exists('onedrive.client.state', $_SESSION)) { throw new \Exception('onedrive.client.state undefined in session'); } $onedrive = new Client(array('state' => $_SESSION['onedrive.client.state'])); if (!array_key_exists('id', $_GET)) { throw new \Exception('id undefined in $_GET'); } $properties = array(); if (!empty($_GET['id'])) { $properties['id'] = $_GET['id']; } if (!empty($_GET['destination_id'])) { $properties['destination_id'] = $_GET['destination_id']; } $id = $_GET['id']; $file = $onedrive->fetchObject($id); if ($file->isFolder()) { throw new \Exception('OneDrive does not support copying folders'); } $file->copy($_GET['destination_id']); $status = sprintf('<p class=bg-success>The file <em>%s</em> has been copied using the <code>File::copy</code> method.</p>', htmlspecialchars($id)); } catch (\Exception $e) { $status = sprintf('<p class=bg-danger>The file <em>%s</em> has <strong>not</strong> been copied using the <code>File::copy</code> method. Reason: <cite>%s</cite></p>', htmlspecialchars($id), htmlspecialchars($e->getMessage())); } ?> <!DOCTYPE html> <html lang=en dir=ltr> <head> <meta charset=utf-8> <title>Copying a OneDrive file – Demonstration of the OneDrive SDK for PHP</title> <link rel=stylesheet href=//ajax.aspnetcdn.com/ajax/bootstrap/3.2.0/css/bootstrap.min.css>
if (!array_key_exists('onedrive.client.state', $_SESSION)) { throw new \Exception('onedrive.client.state undefined in session'); } $onedrive = new Client(array('state' => $_SESSION['onedrive.client.state'])); if (!array_key_exists('id', $_GET)) { throw new \Exception('id undefined in $_GET'); } $properties = array(); if (!empty($_GET['id'])) { $properties['id'] = $_GET['id']; } if (!empty($_GET['destination_id'])) { $properties['destination_id'] = $_GET['destination_id']; } $id = $_GET['id']; $object = $onedrive->fetchObject($_GET['id']); $object->move($_GET['destination_id']); $status = sprintf('<p class=bg-success>The object <em>%s</em> has been moved in your OneDrive account using the <code>Object::move</code> method.</p>', htmlspecialchars($id)); } catch (\Exception $e) { $status = sprintf('<p class=bg-danger>The object <em>%s</em> has <strong>not</strong> been moved in your OneDrive account using the <code>Object::move</code> method. Reason: <cite>%s</cite></p>', htmlspecialchars($id)); } ?> <!DOCTYPE html> <html lang=en dir=ltr> <head> <meta charset=utf-8> <title>Moving a OneDrive object – Demonstration of the OneDrive SDK for PHP</title> <link rel=stylesheet href=//ajax.aspnetcdn.com/ajax/bootstrap/3.2.0/css/bootstrap.min.css> <link rel=stylesheet href=//ajax.aspnetcdn.com/ajax/bootstrap/3.2.0/css/bootstrap-theme.min.css> <meta name=viewport content="width=device-width, initial-scale=1"> </head>