Skip to content
Jonathan Lovatt edited this page Feb 20, 2014 · 30 revisions

Welcome to php-skydrive.

It's a client library for PHP to simplify communication with Microsoft's SkyDrive REST API.

Important

  • This is absolutely a work in progress, it's not yet complete so please use with caution.
  • Exceptions will be thrown when a non-expected HTTP status code is returned.
  • Documentation is a work in progress too!

Requirements

Simple Install

  • Download the library.
  • Put it somewhere accessible by your code.
  • In your PHP code / header file etc, require the library.
  • e.g. require_once "functions.inc.php"
  • Set your security and token store information in functions.inc.php, see Documentation for info.

Getting Started

  • Get an oAuth redirect URL $url = skydrive_auth::build_oauth_url();
  • Redirect user to that URL to log into their Windows Live account.
  • Get an oAuth token on your callback page $response = skydrive_auth::get_oauth_token($_GET['code']);
  • Optional: Store the oAuth token skydrive_tokenstore::save_tokens_to_store($response);
  • Create an object and call the API!
<?php
$token = skydrive_tokenstore::acquire_token();
if (!$token) {
	echo "No access_token available. You need to login first.";
} else {
	$sd = new skydrive($token);
	try {
		$response = $sd->get_quota();
		print_r($response); // Request succeeded, print response
	} catch (Exception $e) {
		echo $e->getMessage(); // Request failed, print error
	}
}
?>

Making Future Requests

  • You can call skydrive_tokenstore::acquire_token if you are using the Token store to get an access token and supply this to the skydrive object. This will automatically handle refreshing tokens for you.

Known Issues

  • SkyDrive's API isn't that fast, so making lots of calls on a single page is discouraged.

Need help/info?

Clone this wiki locally