Access SkyDrive using PHP and OAuth

I would like to access skyDrive using PHP. I want to restore the list of files and folders, upload, download and delete files.

I have microsoft dev client identifier and clientSecret.

Can I start by connecting to skyDrive with OAuth and using the API?

Thank you so much!

+7
source share
1 answer

This is actually a fairly broad question. Here, hopefully something to help you get started.


Try the API

Here is an interactive API where you can try living in order to see the answers.


Query execution

Example (taken from another SO answer):

 $url = 'POST https://apis.live.net/v5.0/me/skydrive/files'; $ch = curl_init(); curl_setopt($ch,CURLOPT_URL, $url); curl_setopt($ch,CURLOPT_POSTFIELDS, array('access_token' => TOKEN, 'name' => 'file', 'filename' => "@HelloWorld.txt")); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $result = curl_exec($ch); curl_close($ch); 

Request Types: http://msdn.microsoft.com/en-us/library/live/hh243648.aspx#http_verbs

I also recommend that you take a look at curl_setopt() to better understand how to perform the various types of queries you will need using cURL. (Also this answer to SO has a good explanation in POST and GET using cURL.)


File object

  • DELETE FILES:

    To delete a file, make a DELETE query in / FILE _ID.

  • DOWNLOAD FILES:

    To create a new file resource, you can either send a POST request to / FOLDER_ID / files, or a POST request to / UPLOAD _LOCATION for the destination folder, or a PUT request to / FOLDER _ID / files /.

  • DOWNLOAD FILES:

    To get the properties of the File resource, make a GET request in / FILE _ID (the identifier of the target file).

    • The file resource will contain a URL from which you can download the file from SkyDrive in the source field.

<h / ">

Folder object

  • RETRIEVE FILES LIST:

    To get the root folder resource using the Live Connect REST API, make a GET request to / me / skydrive or / USER_ID / skydrive.

    To get the subfolder resource, run the GET request in / FOLDER _ID.

  • CREATE FOLDERS:

    To create a new folder resource, enter the POST request in / FOLDER _ID. Pass name and description attributes in the request body

  • REMOVE FOLDERS:

    To delete a folder, query DELETE / FOLDER_ID.


OAuth 2.0

My experience with OAuth is unfortunately limited. I can only provide some relevant links and tips that I hope will help.

Review the protocol overview and consider whether you want to implement something yourself or use the library. A quick google search gives me:

Some other potentially useful links and guides:

+13
source

All Articles