1.11M Members

Access SkyDrive Using PHP

 
0
 

Hello Community,
I was wondering if there is a way to access SkyDrive using php i have looked at so many forums and i could not find anything and what i did find was too complicated to understand, what i want is a way to create files or folders, get files and delete files or folders.

 
0
 

I went to that but i don't know how to use it.

 
1
 

I went to that but i don't know how to use it.

There's a live SDK: http://isdk.dev.live.com/ISDK.aspx

Don't know what more to suggest. There's even a video: http://channel9.msdn.com/Events/BUILD/BUILD2011/PLAT-134C

Learning and experimenting with new API takes time and effort. It'll take you a good few hours, if not more.

 
1
 

In addition to what Diafol already mentioned, you can use plain javascript for OR use the REST. You will need to read more on how to implement the REST in this API, then and ONLY then you can convert the REST codes to PHP using the cURL plugins.

Yes, it will take you some time, but the learning experience is priceless.

To use the REST API, you can read more about it here.

basic syntax for the REST connection

 https://apis.live.net/v5.0/me/albums?access_token=ACCESS_TOKEN 

basic REST syntax for the skydrive as suggested by the microsoft

    POST https://apis.live.net/v5.0/me/skydrive/files?access_token=ACCESS_TOKEN 

Basic information for POST and GET for cURL are shown here.

basic implementation of POST using cURL to the skydrive api,, just like the apis.live...albums

$url = 'POST https://apis.live.net/v5.0/me/skydrive/files';
$form_data = array(
              'token'=> 'ACCESS_TOKEN',
              'file' => 'FILE_NAME',
              'name' => 'NAME_OF_DIRECTORY'
              )

send the data to the API using the cURL "CURLOPT_POSTFIELDS "

$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $form_data);
$result = curl_exec($ch);
curl_close($ch);

the rest are just a matter of retrieving the data response from the remote server..

I am not sure if the skydrive response is json encoded array. If it is, then you can probably get away with it by passing the cURL output ( response from the remote server)...use something like this to test the response from the skydrive.

use var_dump to view the response array from the remote server..

    var_dump(json_decode($result));

That's pretty much it... the rest is all up to you to experiment...

 
0
 

Can i just ask, what is that code supposed to do because the only response i'm getting is "NULL".

This is what i'm trying:

<?php
    $url = 'POST https://apis.live.net/v5.0/me/skydrive/files';
    $form_data = array(
        'token'=> 'ACCESS_TOKEN',
        'file' => 'Test',
        'name' => 'me'
    );

    $ch = curl_init();
    curl_setopt($ch,CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $form_data);
    $result = curl_exec($ch);
    var_dump(json_decode($result));
    curl_close($ch);
?>

Also i don't know where to get the access token.

 
0
 

You get an access token, after the user has logged in. Read more here, or read more about the OAuth flow here.

You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: